1 // Copyright 2012 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 #![allow(unknown_features)]
12 #![feature(box_syntax)]
17 struct Ints {sum: Box<isize>, values: Vec<isize> }
19 fn add_int(x: &mut Ints, v: isize) {
21 let mut values = Vec::new();
22 swap(&mut values, &mut x.values);
24 swap(&mut values, &mut x.values);
27 fn iter_ints<F>(x: &Ints, mut f: F) -> bool where F: FnMut(&isize) -> bool {
28 let l = x.values.len();
29 (0..l).all(|i| f(&x.values[i]))
33 let mut ints: Box<_> = box Ints {sum: box 0, values: Vec::new()};
34 add_int(&mut *ints, 22);
35 add_int(&mut *ints, 44);
37 iter_ints(&*ints, |i| {
38 println!("isize = {:?}", *i);
42 println!("ints={:?}", ints);