From 59c1d54801a86fc6b485ff1871f6ea0b998dd7d9 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Tue, 6 Dec 2022 17:32:44 +0100 Subject: [PATCH] 2022 day6/rust: relax type bounds --- 2022/day6/rust/src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/2022/day6/rust/src/main.rs b/2022/day6/rust/src/main.rs index c02b708..2b6e0e1 100644 --- a/2022/day6/rust/src/main.rs +++ b/2022/day6/rust/src/main.rs @@ -2,17 +2,15 @@ use std::io::{stdin, Read}; -fn all_distinct(slice: &[T]) -> bool { +fn all_distinct(slice: &[T]) -> bool { slice .iter() .enumerate() .all(|(i, x)| slice[i + 1..].iter().all(|y| y != x)) } -fn end_of_first_distinct_run(data: &[T], len: usize) -> Option { - data.windows(len) - .position(|cs| all_distinct(cs)) - .map(|i| i + len) +fn end_of_first_distinct_run(data: &[T], len: usize) -> Option { + data.windows(len).position(all_distinct).map(|i| i + len) } fn main() {