2024-06-21 12:14:19 -04:00
|
|
|
fn main() {
|
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
// TODO: Fix the compiler errors only by reordering the lines in the test.
|
|
|
|
// Don't add, change or remove any line.
|
|
|
|
#[test]
|
2024-07-10 07:50:39 -04:00
|
|
|
fn move_semantics4() {
|
|
|
|
let mut x = Vec::new();
|
2024-06-21 12:14:19 -04:00
|
|
|
let y = &mut x;
|
|
|
|
// `y` used here.
|
2024-07-10 07:50:39 -04:00
|
|
|
y.push(42);
|
2024-06-21 12:14:19 -04:00
|
|
|
// The mutable reference `y` is not used anymore,
|
|
|
|
// therefore a new reference can be created.
|
|
|
|
let z = &mut x;
|
2024-07-10 07:50:39 -04:00
|
|
|
z.push(13);
|
|
|
|
assert_eq!(x, [42, 13]);
|
2024-06-21 12:14:19 -04:00
|
|
|
}
|
|
|
|
}
|