Anonymous user
Deepcopy: Difference between revisions
→{{header|Rust}}
(Removing omission from C after adding implementation.) |
|||
Line 1,525:
This is what the <code>Clone</code> trait exists for although the depth of the copy is arbitrary and up to the type that implements the trait.
<lang rust>
#[derive(Clone)]
struct Tree<T> {
Line 1,536:
impl<T> Tree<T> {
fn root(
}
fn leaf(d: T) -> Leaf<T> {
Some(Box::new(
}
}
fn main() {
let mut tree = Tree::root(
tree.right = Tree::leaf(
tree.left = Tree::leaf(
let newtree = tree.clone();
}</lang>
|