Closed chinoto closed 2 years ago
You can find out the type of a value by assigning it to a variable, supplying the wrong type, and cargo check will tell you what it found the type to actually be, such as let _: () = vec.iter().skip(5).take(5).cycle();
gives
error[E0308]: mismatched types
--> src/lib.rs:432:21
|
432 | let _: () = vec.iter().skip(5).take(5).cycle();
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Cycle`
| |
| expected due to this
|
= note: expected unit type `()`
found struct `Cycle<std::iter::Take<Skip<std::slice::Iter<'_, Vec<(K, V)>>>>>`
Then you just replace '_
with an explicit lifetime and it works.
Didn't know you could IterSlices like that, neat!