File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
- // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- // compile-flags: -Z borrowck=mir -Z nll
12
-
13
- // This example comes from the NLL RFC.
11
+ #![ feature( nll) ]
14
12
15
13
struct List < T > {
16
14
value : T ,
17
15
next : Option < Box < List < T > > > ,
18
16
}
19
17
20
- fn to_refs < T > ( list : & mut List < T > ) -> Vec < & mut T > {
21
- let mut list = list;
18
+ fn to_refs < T > ( mut list : & mut List < T > ) -> Vec < & mut T > {
22
19
let mut result = vec ! [ ] ;
23
20
loop {
24
21
result. push ( & mut list. value ) ;
@@ -31,4 +28,7 @@ fn to_refs<T>(list: &mut List<T>) -> Vec<&mut T> {
31
28
}
32
29
33
30
fn main ( ) {
31
+ let mut list = List { value : 1 , next : None } ;
32
+ let vec = to_refs ( & mut list) ;
33
+ assert_eq ! ( vec![ & mut 1 ] , vec) ;
34
34
}
You can’t perform that action at this time.
0 commit comments