daily pastebin goal
8%
SHARE
TWEET

[Rust] Ownership issues in functions

cwchen Aug 27th, 2017 229 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let v = vec![1, 2, 3];
  3.  
  4.     // v is moved into do_nothing
  5.     do_nothing(v);
  6.  
  7.     // Error when accessing v
  8.     println!("{}", v[1]);
  9. }
  10.  
  11. fn do_nothing(v: Vec<i32>) {
  12.     // Do nothing here.
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top