Created
September 28, 2014 17:43
-
-
Save arielb1/12946daa1f26c612e63c to your computer and use it in GitHub Desktop.
This file contains 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 TypeFoldable { | |
fn fold_with(&self) -> Self; | |
} | |
impl<'a> TypeFoldable for &'a uint { | |
fn fold_with(&self) -> &'a uint { *self } | |
} | |
trait Subst { | |
fn subst(&self) -> Self; | |
} | |
impl<T: TypeFoldable> Subst for T { | |
fn subst(&self) -> T { | |
(*self).fold_with() | |
} | |
} | |
fn main() { | |
let a = &5u; | |
println!("{}", a.subst()); | |
} |
This file contains 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
test.rs:21:18: 21:27 error: the trait `TypeFoldable` is not implemented for the type `uint` | |
test.rs:21 println!("{}", a.subst()); | |
^~~~~~~~~ | |
note: in expansion of format_args! | |
<std macros>:2:23: 2:77 note: expansion site | |
<std macros>:1:1: 3:2 note: in expansion of println! | |
test.rs:21:3: 21:29 note: expansion site | |
error: aborting due to previous error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment