[2018][rust][3.1] cargo fmt

sorbet
Alpha Chen 6 years ago
parent 71fb3478c3
commit 0443116fde

@ -21,15 +21,18 @@ fn solve(input: &str) -> Result<String, Box<Error>> {
.map(str::trim) .map(str::trim)
.map(Claim::from_str) .map(Claim::from_str)
.collect::<Result<_, _>>()?; .collect::<Result<_, _>>()?;
let fabric = claims.iter().fold(HashMap::new(), |mut fabric: HashMap<(usize, usize), Vec<usize>>, claim| { let fabric = claims.iter().fold(
for square_inch in claim.square_inches() { HashMap::new(),
|mut fabric: HashMap<(usize, usize), Vec<usize>>, claim| {
for square_inch in claim.square_inches() {
fabric
.entry(square_inch)
.and_modify(|ids| ids.push(claim.id))
.or_insert(vec![claim.id]);
}
fabric fabric
.entry(square_inch) },
.and_modify(|ids| ids.push(claim.id)) );
.or_insert(vec![claim.id]);
}
fabric
});
let values: Vec<_> = fabric.values().collect(); let values: Vec<_> = fabric.values().collect();
let output = values let output = values
.iter() .iter()

Loading…
Cancel
Save