about summary refs log tree commit diff
path: root/src/test/run-pass/move-out-of-field.rs
blob: 6cf207e5cbc2ce21ae068eca47c05120818c3da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct StringBuffer {
    s: ~str
}

impl StringBuffer {
    pub fn append(&mut self, v: &str) {
        self.s.push_str(v);
    }
}

fn to_str(sb: StringBuffer) -> ~str {
    sb.s
}

pub fn main() {
    let mut sb = StringBuffer {s: ~""};
    sb.append("Hello, ");
    sb.append("World!");
    let str = to_str(sb);
    assert_eq!(str, ~"Hello, World!");
}