Code
fn main() {
let s = String::from("hello");
dbg!(s);
drop(s);
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0382]: use of moved value: `s`
--> src/main.rs:4:10
|
2 | let s = String::from("hello");
| - move occurs because `s` has type `String`, which does not implement the `Copy` trait
3 | dbg!(s);
| ------- value moved here
4 | drop(s);
| ^ value used here after move
|
help: borrow this binding in the pattern to avoid moving the value
--> /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/macros.rs:364:13
|
36| ref tmp => {
| +++
For more information about this error, try `rustc --explain E0382`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
Compiling playground v0.0.1 (/playground)
error[E0382]: use of moved value: `s`
--> src/main.rs:4:10
|
2 | let s = String::from("hello");
| - move occurs because `s` has type `String`, which does not implement the `Copy` trait
3 | dbg!(s);
| ------- value moved here
4 | drop(s);
| ^ value used here after move
|
help: borrow here
|
3 | dbg!(&s);
|
Rationale and extra context
No response
Other cases
No response
Rust Version
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
No response
Other cases
No response
Rust Version
Anything else?
No response