Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. fn main() {
  2. let mut _2d = Vec::new();
  3. _2d.push(Vec::new());
  4. match _2d.last() {
  5. Some(v) => v.push(1i),
  6. None => ()
  7. }
  8. println!("{}", _2d);
  9. }
  10.  
  11. test.rs:6:20: 6:21 error: cannot borrow immutable dereference of `&`-pointer `*v` as mutable
  12. test.rs:6 Some(v) => v.push(1i),
  13.  
  14. test.rs:6:14: 6:20 error: cannot move out of dereference of `&`-pointer
  15. test.rs:6 Some(&mut v) => v.push(1i),
  16. ^~~~~~
  17. 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)
  18. test.rs:6 Some(&mut v) => v.push(1i),
  19.  
  20. test.rs:6:15: 6:24 error: cannot borrow immutable dereference of `&`-pointer as mutable
  21. test.rs:6 Some(&ref mut v) => v.push(1i),
  22.  
  23. fn main() {
  24. let mut _2d = Vec::new();
  25. _2d.push(Vec::new());
  26. match _2d.last_mut() {
  27. Some(v) => v.push(1),
  28. None => ()
  29. }
  30. println!("{:?}", _2d);
  31. }
  32.  
  33. fn main() {
  34. let vec_2d = vec![vec![1i32]];
  35.  
  36. println!("{:?}", vec_2d);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement