DEV Community

Discussion on: Structs in Rust

Collapse
 
sdrsdr profile image
Stoian Ivanov

Instances from other instances example is not really good! User.email is moved to new_user and if you try to use it the compiler gets engry 😃

Collapse
 
francescoxx profile image
Francesco Ciulla

There are different ways to avoid this (I explain it in the video but I didn't want to make the article too long). you can either clone() the single propery or even clone the whole instance adding the clone trait to the struct