Hello everyone, I've been pretty enamored with Rust the past few weeks, and I'm loving the language so far. However, there is one feature of generics that doesn't seem to exist in the language, which is being able to call static methods on type parameters (provided that the type parameter can be guaranteed to implement it). I'm not all that familiar with the technical details of the language, so I'm not sure if this is impossible, or just decided against for some reason. I'm not even sure if I'm using the terminology correctly, so let me illustrate with some code:
trait Newable { fn new() -> Self; } struct Foo(int); impl Newable for Foo { fn new() -> Foo { return Foo(1); } } fn getOneOfThese<T : Newable>() -> T { T::new() } fn main() { let test = getOneOfThese<Foo>(); } But, this code is currently invalid. Could this be a useful addition to the language? Thank you, Dylan Knutson
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev