|
|
@ -27,7 +27,7 @@ mod wrapped {
|
|
27
|
27
|
}
|
|
28
|
28
|
|
|
29
|
29
|
mod list_with_box {
|
|
30
|
|
#[deriving(Show)]
|
|
|
30
|
#[deriving(Clone, Show)]
|
|
31
|
31
|
pub enum List<A> {
|
|
32
|
32
|
Nil,
|
|
33
|
33
|
Cons(A, Box<List<A>>)
|
|
|
@ -53,9 +53,12 @@ mod list_with_box {
|
|
53
|
53
|
println!("\nlist_with_box:");
|
|
54
|
54
|
|
|
55
|
55
|
let l: List<int> = cons(1, cons(2, Nil));
|
|
|
56
|
// must be cloned before use as parameter to cons, which moves it
|
|
|
57
|
let l2 = l.clone();
|
|
56
|
58
|
|
|
57
|
59
|
println!("l = {}", l);
|
|
58
|
|
println!("cons(3, l) = {:?}", cons(3, l));
|
|
|
60
|
println!("cons(3, l) = {:?}", cons(3, l));
|
|
|
61
|
println!("cons(4, l2) = {:?}", cons(4, l2));
|
|
59
|
62
|
|
|
60
|
63
|
// println!("cons_with_ref(3, &l) = {:?}", cons_with_ref(3, &l));
|
|
61
|
64
|
// // ^ "use of moved value: `l`"
|