Просмотр исходного кода

add commented-out, failing example for cons with references.

Lucas Stadler лет назад: 11
Родитель
Сommit
ada418c050
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      rust/pointers.rs

+ 11 - 0
rust/pointers.rs

41
        }
41
        }
42
    }
42
    }
43
43
44
    // pub fn cons_with_ref<A>(x: A, xs: &List<A>) -> List<A> {
45
    //     match *xs {
46
    //         Nil => Cons(x, box Nil),
47
    //         _ => Cons(x, box *xs)
48
    //                       // ^    "cannot move out of dereference of `&`-pointer"
49
    //     }
50
    // }
51
44
    pub fn run() {
52
    pub fn run() {
45
        println!("\nlist_with_box:");
53
        println!("\nlist_with_box:");
46
54
48
56
49
        println!("l = {}", l);
57
        println!("l = {}", l);
50
        println!("cons(3, l) = {:?}", cons(3, l));
58
        println!("cons(3, l) = {:?}", cons(3, l));
59
60
        // println!("cons_with_ref(3, &l) = {:?}", cons_with_ref(3, &l));
61
        //                                                        // ^    "use of moved value: `l`"
51
    }
62
    }
52
}
63
}
53
64