1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-23 14:06:16 +02:00

Tweak solution to iter exercise (#1884)

Because `.zip()` is limited to the shorter length, the `.take()` call
here is unnecessary. When explaining this solution I don't want to have
to explain a call to a method that, used as it is, does nothing.
This commit is contained in:
Frances Wingerter 2024-03-06 20:18:31 +00:00 committed by GitHub
parent c866c13b68
commit 429694fa63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,7 +27,7 @@ where
// ANCHOR_END: offset_differences
let a = (&values).into_iter();
let b = (&values).into_iter().cycle().skip(offset);
a.zip(b).map(|(a, b)| *b - *a).take(values.len()).collect()
a.zip(b).map(|(a, b)| *b - *a).collect()
}
// ANCHOR: unit-tests