2022 day1/rust: avoid unnecessary allocations
This commit is contained in:
parent
8a192ddc42
commit
bd13011a52
1 changed files with 8 additions and 2 deletions
|
@ -1,7 +1,13 @@
|
|||
use std::{cmp::Reverse, io::stdin};
|
||||
use std::{
|
||||
cmp::Reverse,
|
||||
io::{stdin, Read},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let lines: Vec<_> = stdin().lines().map(Result::unwrap).collect();
|
||||
let mut data = String::new();
|
||||
stdin().read_to_string(&mut data).unwrap();
|
||||
|
||||
let lines: Vec<_> = data.lines().collect();
|
||||
let mut elves: Vec<_> = lines
|
||||
.split(|s| s.is_empty())
|
||||
.map(|entries| {
|
||||
|
|
Loading…
Reference in a new issue