[rust-dev] "expected type parameter but found type parameters"

Patrick Walton pwalton at mozilla.com
Wed Dec 26 10:18:53 PST 2012


On 12/26/12 12:23 PM, Paul Nathan wrote:
> Good morning,
>
> I am exploring Rust's traits in relation to working on data
> structures. Unfortunately, I have managed to back myself into a hole
> with an error message that I can't understand the problem with; to
> wit, "has an incompatible type: expected type parameter but found
> type parameter" is an error I don't understand.
>
> I've stuffed the code up on github:
> https://github.com/pnathan/flaky-data-structures/tree/non-compiling

Remove the extra <T> from your methods. You want the traits to look like:

     trait Queue<T> : List<T> {
         fn peek(seq: @self) -> Option<@T>;
         fn pop(seq: @self) -> (Option<@T>, @self);
     }

Not like:

     trait Queue<T> : List<T> {
         fn peek<T>(seq: @self) -> Option<@T>;
         fn pop<T>(seq: @self) -> (Option<@T>, @self);
     }

Patrick



More information about the Rust-dev mailing list