fork download
  1. #[derive(Debug)]
  2. struct MyStruct{}
  3.  
  4. fn move_here(_s: MyStruct) {}
  5.  
  6. fn main() {
  7. let s = MyStruct{};
  8.  
  9. move_here(s);
  10.  
  11. // Not compilable - moved already
  12. println!("{:?}", s)
  13. }
  14.  
Compilation error #stdin compilation error #stdout 0.01s 5284KB
stdin
Standard input is empty
compilation info
error[E0382]: use of moved value: `s`
  --> prog.rs:12:19
   |
9  |     move_here(s);
   |               - value moved here
...
12 |     println!("{:?}", s)
   |                      ^ value used here after move
   |
   = note: move occurs because `s` has type `MyStruct`, which does not implement the `Copy` trait

error: aborting due to previous error

For more information about this error, try `rustc --explain E0382`.
stdout
Standard output is empty