Created
May 14, 2016 14:02
-
-
Save cocuh/77ec15f1ab58b06d6db5870ba4cfd8d0 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 Behaviour { | |
fn run(&self); | |
} | |
struct YoujoBehaviour{} | |
impl Behaviour for YoujoBehaviour{ | |
fn run(&self){println!("はわわ");} | |
} | |
struct Caller<'a> { | |
behaviour: Box<Behaviour+'a>, | |
} | |
impl<'a> Caller<'a> { | |
fn run(&self) { | |
self.behaviour.run(); | |
} | |
} | |
fn main(){ | |
let c = Caller{behaviour: Box::new(YoujoBehaviour{})}; | |
c.run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment