Use lines instead of split('\n')
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julius 2021-12-02 15:24:20 +01:00
parent 797c33b090
commit 666675342d
Signed by: j00lz
GPG key ID: AF241B0AA237BBA2
2 changed files with 3 additions and 3 deletions

View file

@ -3,7 +3,7 @@ pub struct Day01(Vec<i32>);
impl crate::day::Day for Day01 { impl crate::day::Day for Day01 {
fn init(f: String) -> Self { fn init(f: String) -> Self {
let v = f.split('\n').map(|x| x.parse::<i32>().unwrap()).collect::<Vec<i32>>(); let v = f.lines().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<i32>>();
Self(v) Self(v)
} }

View file

@ -10,7 +10,7 @@ enum Instruction {
impl Day for Day02 { impl Day for Day02 {
fn init(content: String) -> Self { fn init(content: String) -> Self {
let lines = content.split("\n").map(str_to_instr).collect::<Vec<Instruction>>(); let lines = content.lines().map(str_to_instr).collect::<Vec<Instruction>>();
Day02(lines) Day02(lines)
} }
@ -100,6 +100,6 @@ forward 2";
#[should_panic] #[should_panic]
fn very_invalid_input(){ fn very_invalid_input(){
let f = String::from("invalid 10"); let f = String::from("invalid 10");
let d = Day02::init(f); Day02::init(f);
} }
} }