Skip to content

Instantly share code, notes, and snippets.

@gifnksm
Created October 26, 2014 02:12
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 gifnksm/41c8f65844b31d1f8240 to your computer and use it in GitHub Desktop.
Save gifnksm/41c8f65844b31d1f8240 to your computer and use it in GitHub Desktop.
struct Doc;
#[cfg(not(phantom))]
struct Node<'a> {
doc: &'a Doc
}
#[cfg(phantom)]
struct Node<'a>;
impl Doc {
#[cfg(phantom)]
fn node<'a>(&'a self) -> Node<'a> {
Node
}
#[cfg(not(phantom))]
fn node<'a>(&'a self) -> Node<'a> {
Node { doc: self }
}
}
fn main() {
let node;
{
let doc = Doc;
node = doc.node();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment