Skip to content

Instantly share code, notes, and snippets.

@arielb1
Created September 28, 2014 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielb1/12946daa1f26c612e63c to your computer and use it in GitHub Desktop.
Save arielb1/12946daa1f26c612e63c to your computer and use it in GitHub Desktop.
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());
}
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