mirror of
https://github.com/wezm/advent-of-code.git
synced 2024-11-12 18:58:00 +00:00
20 lines
470 B
Rust
20 lines
470 B
Rust
|
use std::fs::File;
|
||
|
use std::io;
|
||
|
use std::io::{BufRead, BufReader};
|
||
|
use std::path::Path;
|
||
|
|
||
|
pub fn read_number_list<P: AsRef<Path>>(path: P) -> io::Result<Vec<i32>> {
|
||
|
let input = BufReader::new(File::open(path)?);
|
||
|
let mut output = Vec::new();
|
||
|
|
||
|
for line in input.lines() {
|
||
|
let line = line?;
|
||
|
output.push(
|
||
|
line.parse()
|
||
|
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
Ok(output)
|
||
|
}
|