I’ve just seen that this compiles:
fn main() {
let buf = "32X4aX52";
let result = buf
.split('X')
.filter_map(|n| n.parse::<u32>().ok());
println!("{:?}", result);
}
And it prints:
FilterMap { iter: Split(SplitInternal { start: 0, end: 8, matcher: CharSearcher(CharEqSearcher { char_eq: ‘X’, haystack: “32X4aX52”, char_indices: CharIndices { front_offset: 0, iter: Chars { iter: Iter([51, 50, 88, 52, 97, 88, 53, 50]) } }, ascii_only: true }), allow_trailing_empty: true, finished: false }) }
But this is really different from what I want. I want an output similar to:
[32; 52]