In the following example, Rust 1.22.1 and nightly complain about T of Foobar not being iter::Iterator, which IterWrapper demands.
use std::iter;
struct IterWrapper<T:iter::Iterator> {
iter: T
}
struct Foobar<T> {
w: IterWrapper<T>
}
The suggestion consider adding a "where T: std::iter::Iterator" bound is correct, the main suggestion maybe try calling ".iter()" or a similar method is not applicable to this situation, though.
error[E0277]: the trait bound `T: std::iter::Iterator` is not satisfied
--> src/main.rs:8:5
|
8 | w: IterWrapper<T>
| ^^^^^^^^^^^^^^^^^ `T` is not an iterator; maybe try calling `.iter()` or a similar method
|
= help: the trait `std::iter::Iterator` is not implemented for `T`
= help: consider adding a `where T: std::iter::Iterator` bound
= note: required by `IterWrapper`
error: aborting due to previous error
Same problem for an impl<T> Foobar<T>: Rustc suggest to call .iter() on the type-parameter, which is nonsense.
In the following example, Rust 1.22.1 and nightly complain about
TofFoobarnot beingiter::Iterator, whichIterWrapperdemands.The suggestion
consider adding a "where T: std::iter::Iterator" boundis correct, the main suggestionmaybe try calling ".iter()" or a similar methodis not applicable to this situation, though.Same problem for an
impl<T> Foobar<T>: Rustc suggest to call.iter()on the type-parameter, which is nonsense.