Copy

The Copy trait means that creating a copy of the data value is just a matter of copying the bits that make up its representation. If the data value contains any borrows or uses heap memory, it can't have the Copy trait. 

The compiler will automatically copy data values that have the Copy trait when it would have otherwise moved them.

Since anything that has the Copy trait can certainly be duplicated on request as well, Copy requires Clone to be implemented.

Deriving Copy looks like this:

#[derive(Copy, Clone)]
pub enum CopyExample {
Good,
Bad,
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.144.229