Skip to content

Instantly share code, notes, and snippets.

@hansihe
Forked from anonymous/playground.rs
Created January 7, 2016 07:29
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 hansihe/b61714257dcdecd5afc9 to your computer and use it in GitHub Desktop.
Save hansihe/b61714257dcdecd5afc9 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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