Files
aoc2021/src/utils.rs
T
swaits 77a9b9fcc5 move to include_str!() macro for all data
Move away from I/O to just including the data in the program via macro.
2021-12-04 21:59:10 -07:00

15 lines
324 B
Rust

use anyhow::Result;
use std::str::FromStr;
pub fn parse_data<T: FromStr>(s: &str) -> Result<Vec<T>> {
let mut ret = Vec::new();
for l in s.lines() {
let data = match l.parse::<T>() {
Ok(d) => d,
Err(_) => panic!("parse error"),
};
ret.push(data);
}
Ok(ret)
}