Created
January 7, 2016 07:28
-
-
Save anonymous/5639863d441263413f54 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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
use std::marker::PhantomData; | |
struct Env; | |
#[derive(Clone, Copy)] | |
struct Term<'a> { | |
life: PhantomData<&'a Env>, | |
} | |
// Decodes a Term to a rust value. This interfaces with native code. | |
trait Decoder: Sized { | |
fn decode(env: &Env, term: Term) -> Option<Self>; | |
} | |
// The str this returns would only be valid for the lifetime of env. | |
// Is there any way to give the returned &str an intersection with the lifetime | |
// of the env? | |
// (Calls into C) | |
impl<'a> Decoder for &'a str { | |
fn decode(env: &'a Env, term: Term) -> Option<Self> { | |
None | |
} | |
} | |
fn main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment