[TASK] Day 4 + performance improvements
This commit is contained in:
12
src/util.rs
12
src/util.rs
@@ -3,16 +3,14 @@ use std::fmt::Display;
|
||||
|
||||
use num::Integer;
|
||||
|
||||
pub fn read_file(filename: &str) -> Vec<String> {
|
||||
pub fn read_file(filename: &str) -> String {
|
||||
|
||||
let contents = fs::read_to_string(filename)
|
||||
return fs::read_to_string(filename)
|
||||
.expect("Couldn't read file!");
|
||||
}
|
||||
|
||||
let mut res: Vec<String> = Vec::new();
|
||||
contents.lines().for_each(|l| res.push(String::from(l)));
|
||||
|
||||
res
|
||||
|
||||
pub fn into_lines(input: String) -> Vec<String> {
|
||||
return input.lines().map(|l| l.to_owned()).collect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user