-
-
Save nagisa/72b12e6f0939f0fddfdd 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
#![crate_name="repr"] | |
#![crate_type="rlib"] | |
pub use endpoint::Endpoint; | |
pub use message::Message; | |
mod endpoint { | |
use message::Message; | |
pub struct Endpoint; | |
impl Endpoint { | |
pub fn recvorblock(&self) -> Message { | |
Message | |
} | |
} | |
} | |
mod message { | |
pub struct Message; | |
pub struct SyncMessage; | |
impl Message { | |
pub fn get_sync(self) -> SyncMessage { | |
SyncMessage | |
} | |
} | |
impl SyncMessage { | |
pub fn get_payload<T>(self) -> T { | |
panic!("sync message was not correct type"); | |
} | |
} | |
} |
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
extern crate repr; | |
use repr::Endpoint; | |
fn main() { | |
let ep = Endpoint; | |
let result = ep.recvorblock(); | |
let msg: uint = result.get_sync().get_payload(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment