-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
fn main() {
// You can optionally experiment here.
}
#[cfg(test)]
mod tests {
// TODO: Fix the compiler errors only by reordering the lines in the tes t.
// Don't add, change or remove any line.
#[test]
fn move_semantics4() {
let mut x = Vec::new();
let y = &mut x;
let z = &mut x;
// 同时存在两个可变引用(y 和 z)指向 x,违反了 Rust 的借用规则。
// 在 Rust 中,可变引用在最后一次使用后离开作用域
y.push(42);
z.push(13);
assert_eq!(x, [42, 13]);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels