Hi everyone, I'm doing a bit of Rust coding and I'm trying to build a library to manage some common business object behavior.
trait Field<T> { fn name() -> ~str; fn get_validators() -> ~[&Validator<T>]; fn get(&self) -> T; fn is_valid(&self) -> bool; } trait Model { fn get_fields(&self) -> ~[@Field]; fn validate(&self) -> Option<HashMap<~str, ~[FieldError]>> { } The code fails with the following compiler error: models.rs:80:35: 80:40 error: wrong number of type arguments: expected 1 but found 0 models.rs:80 fn get_fields(&self) -> ~[@Field]; The reason for the get_fields() method is to return a list of heterogenous trait-upcasted objects, and for each of them I'd be invoking the is_valid() method. I would understand that the compiler may not understand the notion of trait return types (which would make sense) but I'd be interested to know whether this is a bug or a design limitation, and in the second case, whether there's a sensible alternative. Thanks -- Andrés Osinski
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev