1 A type that is not a trait was used in a trait position, such as a bound
4 Erroneous code example:
10 impl Foo for Bar {} // error: `Foo` is not a trait
11 fn baz<T: Foo>(t: T) {} // error: `Foo` is not a trait
14 Another erroneous code example:
17 type Foo = Iterator<Item=String>;
19 fn bar<T: Foo>(t: T) {} // error: `Foo` is a type alias
22 Please verify that the trait's name was not misspelled or that the right
23 identifier was used. Example:
31 impl Foo for Bar { // ok!
32 // functions implementation
35 fn baz<T: Foo>(t: T) {} // ok!
38 Alternatively, you could introduce a new trait with your desired restrictions
45 trait Qux: Foo {} // Anything that implements Qux also needs to implement Foo
46 fn baz<T: Qux>(t: T) {} // also ok!
49 Finally, if you are on nightly and want to use a trait alias
50 instead of a type alias, you should use `#![feature(trait_alias)]`:
53 #![feature(trait_alias)]
54 trait Foo = Iterator<Item=String>;
56 fn bar<T: Foo>(t: T) {} // ok!