Thanks, Test::<bool>::new() works indeed.
On 4 June 2014 09:52, Sebastian Gesemann <[email protected]> wrote: > On Wed, Jun 4, 2014 at 9:28 AM, Igor Bukanov wrote: >> What is the syntax for calling a static method of a generic struct >> while selecting the the generic parameters explicitly? Apparently >> Struct<Type>::static_method does not work. For example, consider the >> following program: >> >> #[deriving(Show)] >> struct Test<T> { i: int } >> >> impl<T> Test<T> { >> fn new() -> Test<T> { Test {i: 1} } >> fn test(&self) -> int { self.i } >> } >> >> fn main() { >> let t = Test<bool>::new().test(); >> println!("t={}", t); >> } >> >> The latest nightly compiler generates: >> >> s.rs:10:13: 10:17 error: `Test` is a structure name, but this >> expression uses it like a function name >> s.rs:10 let t = Test<bool>::new().test(); >> ^~~~ > > Not sure if it helps because I can't test it right now and I'm still a > beginner, but here it goes: Try inserting a :: between Test and > <bool>. AFAIU this is sometimes needed for disambiguation. Otherwise > the compiler might think < is a less-than operator. > > Cheers! > sg > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
