feat: move .trim inside read function
This commit is contained in:
parent
000002700e
commit
00000280c2
|
@ -45,7 +45,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aoc"
|
name = "aoc"
|
||||||
version = "27.0.0"
|
version = "28.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"elves",
|
"elves",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "aoc"
|
name = "aoc"
|
||||||
description = "template for advent of code"
|
description = "template for advent of code"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "27.0.0"
|
version = "28.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Matej Janežič <janezic.mj@gmail.com>"]
|
authors = ["Matej Janežič <janezic.mj@gmail.com>"]
|
||||||
|
|
|
@ -24,12 +24,12 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_part_one() {
|
fn test_part_one() {
|
||||||
let input = aoc::read_file("examples", DAY).trim();
|
let input = aoc::read_file("examples", DAY);
|
||||||
assert_eq!(part_one(&input), None);
|
assert_eq!(part_one(&input), None);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_part_two() {
|
fn test_part_two() {
|
||||||
let input = aoc::read_file("examples", DAY).trim();
|
let input = aoc::read_file("examples", DAY);
|
||||||
assert_eq!(part_two(&input), None);
|
assert_eq!(part_two(&input), None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,10 @@ pub fn read_file(folder: &str, day: u8) -> String {
|
||||||
let filepath = cwd.join("src").join(folder).join(format!("{day:02}.txt"));
|
let filepath = cwd.join("src").join(folder).join(format!("{day:02}.txt"));
|
||||||
|
|
||||||
let f = fs::read_to_string(filepath);
|
let f = fs::read_to_string(filepath);
|
||||||
f.expect("could not open input file")
|
f.expect("could not open input file").trim().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_args() -> Result<u8, pico_args::Error> {
|
pub fn parse_args() -> Result<u8, pico_args::Error> {
|
||||||
let mut args = pico_args::Arguments::from_env();
|
let mut args = pico_args::Arguments::from_env();
|
||||||
args.free_from_str()
|
args.free_from_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue