# Module bitflags::__core::clone [−] [src]

The `Clone` trait for types that cannot be 'implicitly copied'.

In Rust, some simple types are "implicitly copyable" and when you assign them or pass them as arguments, the receiver will get a copy, leaving the original value in place. These types do not require allocation to copy and do not have finalizers (i.e. they do not contain owned boxes or implement `Drop`), so the compiler considers them cheap and safe to copy. For other types copies must be made explicitly, by convention implementing the `Clone` trait and calling the `clone` method.

Basic usage example:

    let s = String::new(); // String type implements Clone
    let copy = s.clone(); // so we can clone it

To easily implement the Clone trait, you can also use `#[derive(Clone)]`. Example:

    #[derive(Clone)] // we add the Clone trait to Morpheus struct
    struct Morpheus {
       blue_pill: f32,
       red_pill: i64,
    }

    fn main() {
       let f = Morpheus { blue_pill: 0.0, red_pill: 0 };
       let copy = f.clone(); // and now we can clone it!
    }

## Traits

Clone | A common trait for cloning an object.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)