As somebody new to Rust, I am wondering whether there is a subtle difference between clone and copy in the case of a simple struct like
#[derive(Copy, Clone)]
struct AStruct {
a: i8,
b, i8
}
Copy, clone have the same effect, but are they factually identical in other terms, like performance?
vague
July 6, 2022, 5:08pm
2
The main difference is the semantics.
std doc Clone in std::clone - Rust and Copy in std::marker - Rust are great materials for your question.
2 Likes
jonh
July 6, 2022, 10:59pm
4
You can pass Copy
type to more functions.
Copy is built into the language; you can implement your own clone(). You need an obscure reason to make it different though.
system
Closed
October 4, 2022, 11:00pm
5
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.