2022 day1/rust: avoid unnecessary allocations

This commit is contained in:
Xiretza 2022-12-01 20:41:22 +01:00
parent 8a192ddc42
commit bd13011a52

View file

@ -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| {