2 ms·
I'm trying to do the exact same thing (learning Rust through solving the AoC) but I'm not done yet. Regarding parsing, a lot of times the input format is unnec
by hocuspocus 8y ago
I'm trying to do the exact same thing (learning Rust through solving the AoC) but I'm not done yet.
Regarding parsing, a lot of times the input format is unnecessarily complex. In "real-life", wouldn't you start by sanitizing your input? For me, search/replace and column-edits have been enough to avoid regexps entirely.
- K0nserv 8y agoAgreed. Most of my solutions[0] use something simple like input .lines() .map(|s| s.trim()) .filter(|l| l.len() > 0) .map(CustomType::from) .collect::<Vec<_>>(); or for grid-like puzzels input .lines() .map(|s| s.trim()) .filter(|l| l.len() > 0) .map(|l| l .chars() .map(CustomType::from) .collect::<Vec<_>>() ) .collect::<Vec<_>>(); 0: https://github.com/k0nserv/advent-of-rust-2018 https://github.com/k0nserv/advent-of-rust-2018