Guest User

Untitled

a guest
Jun 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. fn main() {
  2. let x = vec![1u8, 2u8, 3u8];
  3. let y = &x; // the vector was "borrowed"
  4. let c = x.clone(); // Explicit copy
  5. println!("x is {:?}", x);
  6. println!("y is {:?}", *y);
  7.  
  8. fn abc(x: &Vec<u8>) {
  9. // do something
  10. }
  11. let myvec = vec![1u8,2u8,3u8];
  12. abc(&myvec); // Passes a borrowed reference
  13. // Still can use myvec here
  14. }
Add Comment
Please, Sign In to add comment