Open
Description
In Chapter 5 (An Example program using stucts), the example uses a scalar type u32
for the Rectangle
struct with this note underneath
... note that accessing fields of a borrowed struct instance does not move the field values, which is why you often see borrows of structs
https://doc.rust-lang.org/book/ch05-02-example-structs.html
I tried to write the Struct and referenced a string in the update_user
function as seen in the image below. The compiler raised an error
| ^^^^^^^^^ move occurs because `user.name` has type `String`, which does not implement the `Copy` trait
Is that statement correct or do I not fully understand what it mean? Or does the statement only apply to types that implements the Copy
trait? Can anyone explain what the problem is?

Metadata
Metadata
Assignees
Labels
No labels