Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let mut _2d = Vec::new();
- _2d.push(Vec::new());
- match _2d.last() {
- Some(v) => v.push(1i),
- None => ()
- }
- println!("{}", _2d);
- }
- test.rs:6:20: 6:21 error: cannot borrow immutable dereference of `&`-pointer `*v` as mutable
- test.rs:6 Some(v) => v.push(1i),
- test.rs:6:14: 6:20 error: cannot move out of dereference of `&`-pointer
- test.rs:6 Some(&mut v) => v.push(1i),
- ^~~~~~
- test.rs:6:15: 6:20 note: attempting to move value to here (to prevent the move, use `ref v` or `ref mut v` to capture value by reference)
- test.rs:6 Some(&mut v) => v.push(1i),
- test.rs:6:15: 6:24 error: cannot borrow immutable dereference of `&`-pointer as mutable
- test.rs:6 Some(&ref mut v) => v.push(1i),
- fn main() {
- let mut _2d = Vec::new();
- _2d.push(Vec::new());
- match _2d.last_mut() {
- Some(v) => v.push(1),
- None => ()
- }
- println!("{:?}", _2d);
- }
- fn main() {
- let vec_2d = vec![vec![1i32]];
- println!("{:?}", vec_2d);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement