Skip to content

Instantly share code, notes, and snippets.

@MaikKlein
Created July 16, 2014 14:33
Show Gist options
  • Save MaikKlein/ee3f80ce15186de74070 to your computer and use it in GitHub Desktop.
Save MaikKlein/ee3f80ce15186de74070 to your computer and use it in GitHub Desktop.
trait Functor<A>{
fn fmap<B>(f : |A| -> B, v : A) -> B;
}
impl Functor<i32> for i32 {
fn fmap<B>(f : |i32| -> B, v : i32) -> B {
f(v)
}
}
fn main(){
let i:i32 = Functor::fmap(|x: i32| x * 2 , 10);
println!("{}", i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment