Last active
December 16, 2015 14:38
-
-
Save dymk/5449654 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>(); | |
| } | |
| // test.rs:20:1: 20:7 error: unresolved name | |
| // test.rs:20 T::new() | |
| // test ^~~~~~ | |
| // test.rs:20:1: 20:7 error: use of undeclared module `T` | |
| // test.rs:20 T::new() | |
| // test ^~~~~~ | |
| // test.rs:20:1: 20:7 error: unresolved name: `T::new`. | |
| // test.rs:20 T::new() | |
| // test ^~~~~~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment