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.
12 // Test that a `&mut` inside of an `&` is freezable.
15 struct MutSlice
<'a
, T
:'a
> {
19 fn get
<'a
, T
>(ms
: &'a MutSlice
<'a
, T
>, index
: usize) -> &'a T
{
24 let mut data
= [1, 2, 3];
26 let slice
= MutSlice { data: &mut data }
;
28 let index0
= get(&slice
, 0);
29 let index1
= get(&slice
, 1);
30 let index2
= get(&slice
, 2);
31 assert_eq
!(*index0
, 5);
32 assert_eq
!(*index1
, 2);
33 assert_eq
!(*index2
, 3);
35 assert_eq
!(data
[0], 5);
36 assert_eq
!(data
[1], 2);
37 assert_eq
!(data
[2], 3);