Skip to content

Instantly share code, notes, and snippets.

@carl-eastlund
Created August 19, 2013 05:16
Show Gist options
  • Select an option

  • Save carl-eastlund/6265928 to your computer and use it in GitHub Desktop.

Select an option

Save carl-eastlund/6265928 to your computer and use it in GitHub Desktop.
derived cloning, expanded
priv use std::prelude::*;
priv extern mod std;
/* This version works: */
// Box{ unbox : b.unbox.clone() }
/* This version doesn't: */
mod __std_macros {
#[macro_escape];
#[doc(hidden)];
priv use std::prelude::*;
#[cfg(not(debug))]
#[macro_escape]
mod debug_macro {
priv use std::prelude::*;
}
}
fn main() { }
#[deriving(Clone)]
struct Box<T> {
unbox: @T,
}
#[doc = "Automatically derived."]
pub impl <T: ::std::clone::Clone> ::std::clone::Clone for Box<T> {
fn clone(&self) -> Box<T> {
match *self {
Box{unbox: ref __self_0_0} => Box{unbox: __self_0_0.clone(),}
}
}
}
fn op<T>(b: Box<T>) -> Box<T> { b.clone() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment