mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
27 lines
397 B
Rust
27 lines
397 B
Rust
struct Node {
|
|
elem: i32,
|
|
next: Option<Box<Node>>,
|
|
}
|
|
|
|
fn a() {
|
|
let mut node = Node {
|
|
elem: 5,
|
|
next: None,
|
|
};
|
|
|
|
let mut src = &mut node;
|
|
{src};
|
|
src.next = None; //~ ERROR use of moved value: `src` [E0382]
|
|
}
|
|
|
|
fn b() {
|
|
let mut src = &mut (22, 44);
|
|
{src};
|
|
src.0 = 66; //~ ERROR use of moved value: `src` [E0382]
|
|
}
|
|
|
|
fn main() {
|
|
a();
|
|
b();
|
|
}
|