my solutions to advent of code
aoc advent-of-code

split once

aylac.top 1044279a 8e4c8f54

verified
Changed files
+3 -3
2025
2
rust
src
+3 -3
2025/2/rust/src/main.rs
···
.trim()
.split(",")
.map(|v| {
-
let range: Vec<&str> = v.split("-").collect();
-
match range[..] {
-
[start, end] => Range {
+
let range = v.split_once("-");
+
match range {
+
Some((start, end)) => Range {
start: start.parse().expect("invalid number"),
end: end.parse().expect("invalid number"),
},