2014-02-05 16:33:10 -06:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2012-12-14 17:50:48 -08:00
|
|
|
enum E {
|
|
|
|
Foo,
|
2014-05-12 17:56:43 -07:00
|
|
|
Bar(StrBuf)
|
2012-12-14 17:50:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
x: E
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:56:43 -07:00
|
|
|
fn f(x: StrBuf) {}
|
2012-12-14 17:50:48 -08:00
|
|
|
|
|
|
|
fn main() {
|
2014-05-12 17:56:43 -07:00
|
|
|
let s = S { x: Bar("hello".to_strbuf()) };
|
2012-12-14 17:50:48 -08:00
|
|
|
match &s.x {
|
|
|
|
&Foo => {}
|
2013-07-02 12:47:32 -07:00
|
|
|
&Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
|
2012-12-14 17:50:48 -08:00
|
|
|
};
|
|
|
|
match &s.x {
|
|
|
|
&Foo => {}
|
2014-01-09 21:06:55 +11:00
|
|
|
&Bar(ref identifier) => println!("{}", *identifier)
|
2012-12-14 17:50:48 -08:00
|
|
|
};
|
|
|
|
}
|