1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that a `&mut` inside of an `&` is freezable.
13 struct MutSlice<'a, T> {
17 fn get<'a, T>(ms: &'a MutSlice<'a, T>, index: uint) -> &'a T {
22 let mut data = [1, 2, 3];
24 let slice = MutSlice { data: data };
26 let index0 = get(&slice, 0);
27 let index1 = get(&slice, 1);
28 let index2 = get(&slice, 2);
29 assert_eq!(*index0, 5);
30 assert_eq!(*index1, 2);
31 assert_eq!(*index2, 3);
33 assert_eq!(data[0], 1);
34 assert_eq!(data[1], 2);
35 assert_eq!(data[2], 3);