error[E0382]: borrow of moved value: `s`
--> crates/ownership_demo/src/lib.rs:28:26
|
26 | let s = String::from("hello");
| - move occurs because `s` has type `String`, which does not implement the `Copy` trait
27 | takes_ownership(s);
| - value moved here
28 | println!("s:{}", s);
| ^ value borrowed here after move
|
note: consider changing this parameter type in function `takes_ownership` to borrow instead if owning the value isn't necessary
--> crates/ownership_demo/src/lib.rs:1:33
|
1 | fn takes_ownership(some_string: String) {
| --------------- ^^^^^^ this parameter takes ownership of the value
| |
| in this function
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
27 | takes_ownership(s.clone());
| ++++++++
For more information about this error, try `rustc --explain E0382`.
error: could not compile `ownership_demo` (lib test) due to 1 previous error