Skip to main content

Clone

Trait Clone 

1.0.0 (const: unstable) · Source
pub trait Clone: Sized {
    // Required method
    fn clone(&self) -> Self;

    // Provided method
    fn clone_from(&mut self, source: &Self) { ... }
}
Expand description

A common trait that allows explicit creation of a duplicate value.

Calling clone always produces a new value. However, for types that are references to other data (such as smart pointers or references), the new value may still point to the same underlying data, rather than duplicating it. See Clone::clone for more details.

This distinction is especially important when using #[derive(Clone)] on structs containing smart pointers like Arc<Mutex<T>> - the cloned struct will share mutable state with the original.

Differs from Copy in that Copy is implicit and an inexpensive bit-wise copy, while Clone is always explicit and may or may not be expensive. Copy has no methods, so you cannot change its behavior, but when implementing Clone, the clone method you provide may run arbitrary code.

Since Clone is a supertrait of Copy, any type that implements Copy must also implement Clone.

§Derivable

This trait can be used with #[derive] if all fields are Clone. The derived implementation of Clone calls clone on each field.

For a generic struct, #[derive] implements Clone conditionally by adding bound Clone on generic parameters.

// `derive` implements Clone for Reading<T> when T is Clone.
#[derive(Clone)]
struct Reading<T> {
    frequency: T,
}

§How can I implement Clone?

Types that are Copy should have a trivial implementation of Clone. More formally: if T: Copy, x: T, and y: &T, then let x = y.clone(); is equivalent to let x = *y;. Manual implementations should be careful to uphold this invariant; however, unsafe code must not rely on it to ensure memory safety.

An example is a generic struct holding a function pointer. In this case, the implementation of Clone cannot be derived, but can be implemented as:

struct Generate<T>(fn() -> T);

impl<T> Copy for Generate<T> {}

impl<T> Clone for Generate<T> {
    fn clone(&self) -> Self {
        *self
    }
}

If we derive:

#[derive(Copy, Clone)]
struct Generate<T>(fn() -> T);

the auto-derived implementations will have unnecessary T: Copy and T: Clone bounds:


// Automatically derived
impl<T: Copy> Copy for Generate<T> { }

// Automatically derived
impl<T: Clone> Clone for Generate<T> {
    fn clone(&self) -> Generate<T> {
        Generate(Clone::clone(&self.0))
    }
}

The bounds are unnecessary because clearly the function itself should be copy- and cloneable even if its return type is not:

#[derive(Copy, Clone)]
struct Generate<T>(fn() -> T);

struct NotCloneable;

fn generate_not_cloneable() -> NotCloneable {
    NotCloneable
}

Generate(generate_not_cloneable).clone(); // error: trait bounds were not satisfied
// Note: With the manual implementations the above line will compile.

§Clone and PartialEq/Eq

Clone is intended for the duplication of objects. Consequently, when implementing both Clone and PartialEq, the following property is expected to hold:

x == x -> x.clone() == x

In other words, if an object compares equal to itself, its clone must also compare equal to the original.

For types that also implement Eq – for which x == x always holds – this implies that x.clone() == x must always be true. Standard library collections such as HashMap, HashSet, BTreeMap, BTreeSet and BinaryHeap rely on their keys respecting this property for correct behavior. Furthermore, these collections require that cloning a key preserves the outcome of the Hash and Ord methods. Thankfully, this follows automatically from x.clone() == x if Hash and Ord are correctly implemented according to their own requirements.

When deriving both Clone and PartialEq using #[derive(Clone, PartialEq)] or when additionally deriving Eq using #[derive(Clone, PartialEq, Eq)], then this property is automatically upheld – provided that it is satisfied by the underlying types.

Violating this property is a logic error. The behavior resulting from a logic error is not specified, but users of the trait must ensure that such logic errors do not result in undefined behavior. This means that unsafe code must not rely on this property being satisfied.

§Additional implementors

In addition to the implementors listed below, the following types also implement Clone:

  • Function item types (i.e., the distinct types defined for each function)
  • Function pointer types (e.g., fn() -> i32)
  • Closure types, if they capture no value from the environment or if all such captured values implement Clone themselves. Note that variables captured by shared reference always implement Clone (even if the referent doesn’t), while variables captured by mutable reference never implement Clone.

Required Methods§

1.0.0 (const: unstable) · Source

fn clone(&self) -> Self

Returns a duplicate of the value.

Note that what “duplicate” means varies by type:

  • For most types, this creates a deep, independent copy
  • For reference types like &T, this creates another reference to the same value
  • For smart pointers like Arc or Rc, this increments the reference count but still points to the same underlying data
§Examples
let hello = "Hello"; // &str implements Clone

assert_eq!("Hello", hello.clone());

Example with a reference-counted type:

use std::sync::{Arc, Mutex};

let data = Arc::new(Mutex::new(vec![1, 2, 3]));
let data_clone = data.clone(); // Creates another Arc pointing to the same Mutex

{
    let mut lock = data.lock().unwrap();
    lock.push(4);
}

// Changes are visible through the clone because they share the same underlying data
assert_eq!(*data_clone.lock().unwrap(), vec![1, 2, 3, 4]);

Provided Methods§

1.0.0 (const: unstable) · Source

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source.

a.clone_from(&b) is equivalent to a = b.clone() in functionality, but can be overridden to reuse the resources of a to avoid unnecessary allocations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Clone for !

1.26.0 · Source§

impl Clone for AccessError

1.0.0 · Source§

impl Clone for AddrParseError

Source§

impl Clone for std::mem::Alignment

1.28.0 · Source§

impl Clone for std::fmt::Alignment

Source§

impl Clone for AllocError

Source§

impl Clone for AsciiChar

Source§

impl Clone for Assume

Source§

impl Clone for BacktraceStyle

Source§

impl Clone for Big8x3

Source§

impl Clone for Big32x40

Source§

impl Clone for Box<ByteStr>

1.29.0 · Source§

impl Clone for Box<CStr>

1.29.0 · Source§

impl Clone for Box<OsStr>

1.29.0 · Source§

impl Clone for Box<Path>

1.3.0 · Source§

impl Clone for Box<str>

Source§

impl Clone for Buf

Source§

impl Clone for ByteString

1.64.0 · Source§

impl Clone for CString

Source§

impl Clone for CharCase

1.34.0 · Source§

impl Clone for CharTryFromError

Source§

impl Clone for CodePoint

Source§

impl Clone for CodePointInner

Source§

impl Clone for CommandEnv

Source§

impl Clone for Context

1.27.0 · Source§

impl Clone for CpuidResult

Source§

impl Clone for DebugAsHex

Source§

impl Clone for Decimal

Source§

impl Clone for DecimalSeq

1.9.0 · Source§

impl Clone for DecodeUtf16Error

Source§

impl Clone for Decoded

1.7.0 · Source§

impl Clone for DefaultHasher

1.3.0 · Source§

impl Clone for Duration

1.0.0 · Source§

impl Clone for std::io::Empty

1.0.0 · Source§

impl Clone for Error

1.0.0 · Source§

impl Clone for ErrorKind

1.20.0 · Source§

impl Clone for std::char::EscapeDebug

1.0.0 · Source§

impl Clone for std::ascii::EscapeDefault

1.0.0 · Source§

impl Clone for std::char::EscapeDefault

1.0.0 · Source§

impl Clone for std::char::EscapeUnicode

1.61.0 · Source§

impl Clone for std::process::ExitCode

Source§

impl Clone for std::sys::process::unix::common::ExitCode

1.0.0 · Source§

impl Clone for std::process::ExitStatus

Source§

impl Clone for std::sys::process::unix::unix::ExitStatus

Source§

impl Clone for std::process::ExitStatusError

Source§

impl Clone for std::sys::process::unix::unix::ExitStatusError

Source§

impl Clone for FieldId

Source§

impl Clone for FileAttr

Source§

impl Clone for FilePermissions

1.75.0 · Source§

impl Clone for std::fs::FileTimes

Source§

impl Clone for std::sys::fs::unix::FileTimes

1.1.0 · Source§

impl Clone for std::fs::FileType

Source§

impl Clone for std::sys::fs::unix::FileType

Source§

impl Clone for FormattingOptions

Source§

impl Clone for Fp

1.0.0 · Source§

impl Clone for FpCategory

Source§

impl Clone for std::backtrace_rs::backtrace::Frame

Source§

impl Clone for std::backtrace_rs::backtrace::libunwind::Frame

1.69.0 · Source§

impl Clone for FromBytesUntilNulError

1.64.0 · Source§

impl Clone for FromBytesWithNulError

1.0.0 · Source§

impl Clone for FromUtf8Error

1.64.0 · Source§

impl Clone for FromVecWithNulError

Source§

impl Clone for FullDecoded

1.86.0 · Source§

impl Clone for GetDisjointMutError

Source§

impl Clone for Global

Source§

impl Clone for Guard

Source§

impl Clone for I32NotAllOnes

Source§

impl Clone for I64NotAllOnes

1.34.0 (const: unstable) · Source§

impl Clone for Infallible

1.8.0 · Source§

impl Clone for std::time::Instant

Source§

impl Clone for std::sys::time::unix::Instant

1.55.0 · Source§

impl Clone for IntErrorKind

Source§

impl Clone for IntoChars

1.64.0 · Source§

impl Clone for IntoStringError

1.7.0 · Source§

impl Clone for IpAddr

1.0.0 (const: unstable) · Source§

impl Clone for Ipv4Addr

1.0.0 (const: unstable) · Source§

impl Clone for Ipv6Addr

Source§

impl Clone for Ipv6MulticastScope

1.28.0 · Source§

impl Clone for Layout

1.50.0 · Source§

impl Clone for LayoutError

Source§

impl Clone for LocalWaker

Source§

impl Clone for Locality

1.0.0 · Source§

impl Clone for Metadata

Source§

impl Clone for Mode

Source§

impl Clone for Nanoseconds

Source§

impl Clone for NonZeroCharInner

Source§

impl Clone for NonZeroI8Inner

Source§

impl Clone for NonZeroI16Inner

Source§

impl Clone for NonZeroI32Inner

Source§

impl Clone for NonZeroI64Inner

Source§

impl Clone for NonZeroI128Inner

Source§

impl Clone for NonZeroIsizeInner

Source§

impl Clone for NonZeroU8Inner

Source§

impl Clone for NonZeroU16Inner

Source§

impl Clone for NonZeroU32Inner

Source§

impl Clone for NonZeroU64Inner

Source§

impl Clone for NonZeroU128Inner

Source§

impl Clone for NonZeroUsizeInner

1.64.0 · Source§

impl Clone for NulError

1.0.0 · Source§

impl Clone for std::fs::OpenOptions

Source§

impl Clone for std::sys::fs::unix::OpenOptions

Source§

impl Clone for Operation

1.0.0 (const: unstable) · Source§

impl Clone for std::cmp::Ordering

1.0.0 · Source§

impl Clone for std::sync::atomic::Ordering

1.0.0 · Source§

impl Clone for OsString

1.0.0 · Source§

impl Clone for Output

1.0.0 · Source§

impl Clone for ParseBoolError

1.20.0 · Source§

impl Clone for ParseCharError

1.0.0 · Source§

impl Clone for ParseFloatError

1.0.0 · Source§

impl Clone for ParseIntError

1.0.0 · Source§

impl Clone for PathBuf

1.0.0 · Source§

impl Clone for Permissions

1.33.0 · Source§

impl Clone for PhantomPinned

Source§

impl Clone for PrintFmt

Source§

impl Clone for ProgramKind

1.7.0 · Source§

impl Clone for RandomState

1.0.0 (const: unstable) · Source§

impl Clone for RangeFull

1.36.0 · Source§

impl Clone for RawWakerVTable

1.0.0 · Source§

impl Clone for RecvError

1.12.0 · Source§

impl Clone for RecvTimeoutError

Source§

impl Clone for ResumeTy

Source§

impl Clone for SearchStep

1.0.0 · Source§

impl Clone for SeekFrom

Source§

impl Clone for Selected

1.0.0 · Source§

impl Clone for Shutdown

Source§

impl Clone for core::num::imp::flt2dec::Sign

Source§

impl Clone for std::fmt::Sign

1.0.0 · Source§

impl Clone for Sink

1.0.0 · Source§

impl Clone for SipHasher

Source§

impl Clone for SipHasher13

1.0.0 · Source§

impl Clone for std::net::SocketAddr

1.10.0 · Source§

impl Clone for std::os::unix::net::addr::SocketAddr

1.0.0 · Source§

impl Clone for SocketAddrV4

1.0.0 · Source§

impl Clone for SocketAddrV6

Source§

impl Clone for SocketCred

Available on Android or Cygwin or Linux only.
Source§

impl Clone for SpawnHooks

Source§

impl Clone for std::path::State

Source§

impl Clone for std::sys::thread_local::native::eager::State

Source§

impl Clone for StatxExtraFields

1.0.0 · Source§

impl Clone for String

1.7.0 · Source§

impl Clone for StripPrefixError

1.28.0 · Source§

impl Clone for System

Source§

impl Clone for SystemRng

1.8.0 · Source§

impl Clone for std::time::SystemTime

Source§

impl Clone for std::sys::time::unix::SystemTime

1.8.0 · Source§

impl Clone for SystemTimeError

1.0.0 · Source§

impl Clone for Thread

1.19.0 · Source§

impl Clone for ThreadId

Source§

impl Clone for Timespec

Source§

impl Clone for ToCasefold

1.0.0 · Source§

impl Clone for ToLowercase

Source§

impl Clone for ToTitlecase

1.0.0 · Source§

impl Clone for ToUppercase

1.59.0 · Source§

impl Clone for TryFromCharError

1.66.0 · Source§

impl Clone for TryFromFloatSecsError

1.34.0 · Source§

impl Clone for TryFromIntError

1.34.0 · Source§

impl Clone for TryFromSliceError

1.0.0 · Source§

impl Clone for TryRecvError

1.57.0 · Source§

impl Clone for TryReserveError

Source§

impl Clone for TryReserveErrorKind

1.0.0 (const: unstable) · Source§

impl Clone for TypeId

Source§

impl Clone for U32NotAllOnes

Source§

impl Clone for U64NotAllOnes

Source§

impl Clone for UCred

Available on Android or Apple or Cygwin or DragonFly BSD or FreeBSD or Linux or NetBSD or OpenBSD or QNX SDP 7.x or QNX SDP 8.0+ only.
Source§

impl Clone for UnorderedKeyError

Source§

impl Clone for UsizeNoHighBit

1.0.0 · Source§

impl Clone for Utf8Error

1.0.0 · Source§

impl Clone for VarError

1.5.0 · Source§

impl Clone for WaitTimeoutResult

1.36.0 · Source§

impl Clone for Waker

Source§

impl Clone for Wtf8Buf

Source§

impl Clone for XdgDirsIter

1.27.0 · Source§

impl Clone for __m128

1.27.0 · Source§

impl Clone for __m256

1.72.0 · Source§

impl Clone for __m512

1.89.0 · Source§

impl Clone for __m128bh

1.27.0 · Source§

impl Clone for __m128d

1.94.0 · Source§

impl Clone for __m128h

1.27.0 · Source§

impl Clone for __m128i

1.89.0 · Source§

impl Clone for __m256bh

1.27.0 · Source§

impl Clone for __m256d

1.94.0 · Source§

impl Clone for __m256h

1.27.0 · Source§

impl Clone for __m256i

1.89.0 · Source§

impl Clone for __m512bh

1.72.0 · Source§

impl Clone for __m512d

1.94.0 · Source§

impl Clone for __m512h

1.72.0 · Source§

impl Clone for __m512i

Source§

impl Clone for __tile1024i

Source§

impl Clone for bf16

1.0.0 (const: unstable) · Source§

impl Clone for bool

1.0.0 (const: unstable) · Source§

impl Clone for char

1.0.0 (const: unstable) · Source§

impl Clone for f16

1.0.0 (const: unstable) · Source§

impl Clone for f32

1.0.0 (const: unstable) · Source§

impl Clone for f64

1.0.0 (const: unstable) · Source§

impl Clone for f128

1.0.0 (const: unstable) · Source§

impl Clone for i8

1.0.0 (const: unstable) · Source§

impl Clone for i16

1.0.0 (const: unstable) · Source§

impl Clone for i32

1.0.0 (const: unstable) · Source§

impl Clone for i64

1.0.0 (const: unstable) · Source§

impl Clone for i128

1.0.0 (const: unstable) · Source§

impl Clone for isize

1.1.0 · Source§

impl Clone for stat

Available on Linux and (PowerPC64 or WebAssembly or x86-64) only.
1.0.0 (const: unstable) · Source§

impl Clone for u8

1.0.0 (const: unstable) · Source§

impl Clone for u16

1.0.0 (const: unstable) · Source§

impl Clone for u32

1.0.0 (const: unstable) · Source§

impl Clone for u64

1.0.0 (const: unstable) · Source§

impl Clone for u128

1.0.0 (const: unstable) · Source§

impl Clone for usize

Source§

impl<'a, 'b, const N: usize> Clone for CharArrayRefSearcher<'a, 'b, N>

Source§

impl<'a, 'b> Clone for CharSliceSearcher<'a, 'b>

Source§

impl<'a, 'b> Clone for StrSearcher<'a, 'b>

Source§

impl<'a, F> Clone for CharPredicateSearcher<'a, F>
where F: Clone + FnMut(char) -> bool,

Source§

impl<'a, K> Clone for std::collections::btree_set::Cursor<'a, K>
where K: Clone + 'a,

1.5.0 · Source§

impl<'a, P> Clone for MatchIndices<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.2.0 · Source§

impl<'a, P> Clone for Matches<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.5.0 · Source§

impl<'a, P> Clone for RMatchIndices<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.2.0 · Source§

impl<'a, P> Clone for RMatches<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.0.0 · Source§

impl<'a, P> Clone for std::str::RSplit<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.0.0 · Source§

impl<'a, P> Clone for RSplitN<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.0.0 · Source§

impl<'a, P> Clone for RSplitTerminator<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.0.0 · Source§

impl<'a, P> Clone for std::str::Split<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.51.0 · Source§

impl<'a, P> Clone for std::str::SplitInclusive<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.0.0 · Source§

impl<'a, P> Clone for SplitN<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.0.0 · Source§

impl<'a, P> Clone for SplitTerminator<'a, P>
where P: Pattern, <P as Pattern>::Searcher<'a>: Clone,

1.89.0 · Source§

impl<'a, T, P> Clone for ChunkBy<'a, T, P>
where T: 'a, P: Clone,

1.31.0 · Source§

impl<'a, T> Clone for RChunksExact<'a, T>

Source§

impl<'a, const N: usize> Clone for CharArraySearcher<'a, N>

1.28.0 · Source§

impl<'a> Clone for Ancestors<'a>

1.0.0 · Source§

impl<'a> Clone for Arguments<'a>

Source§

impl<'a> Clone for core::ffi::c_str::Bytes<'a>

1.0.0 · Source§

impl<'a> Clone for std::str::Bytes<'a>

Source§

impl<'a> Clone for CStringIter<'a>

1.0.0 · Source§

impl<'a> Clone for CharIndices<'a>

Source§

impl<'a> Clone for CharSearcher<'a>

1.0.0 · Source§

impl<'a> Clone for Chars<'a>

1.0.0 · Source§

impl<'a> Clone for Component<'a>

1.0.0 · Source§

impl<'a> Clone for Components<'a>

Source§

impl<'a> Clone for EHContext<'a>

1.8.0 · Source§

impl<'a> Clone for EncodeUtf16<'a>

1.0.0 · Source§

impl<'a> Clone for EncodeWide<'a>

1.60.0 · Source§

impl<'a> Clone for EscapeAscii<'a>

1.34.0 · Source§

impl<'a> Clone for std::str::EscapeDebug<'a>

1.34.0 · Source§

impl<'a> Clone for std::str::EscapeDefault<'a>

1.34.0 · Source§

impl<'a> Clone for std::str::EscapeUnicode<'a>

Source§

impl<'a> Clone for Formatted<'a>

1.36.0 · Source§

impl<'a> Clone for IoSlice<'a>

1.0.0 · Source§

impl<'a> Clone for std::path::Iter<'a>

1.0.0 · Source§

impl<'a> Clone for Lines<'a>

1.0.0 · Source§

impl<'a> Clone for LinesAny<'a>

1.10.0 · Source§

impl<'a> Clone for Location<'a>

Source§

impl<'a> Clone for Part<'a>

Source§

impl<'a> Clone for PhantomContravariantLifetime<'a>

Source§

impl<'a> Clone for PhantomCovariantLifetime<'a>

Source§

impl<'a> Clone for PhantomInvariantLifetime<'a>

1.0.0 · Source§

impl<'a> Clone for Prefix<'a>

1.0.0 · Source§

impl<'a> Clone for PrefixComponent<'a>

Source§

impl<'a> Clone for Source<'a>

1.34.0 · Source§

impl<'a> Clone for SplitAsciiWhitespace<'a>

1.1.0 · Source§

impl<'a> Clone for SplitWhitespace<'a>

1.79.0 · Source§

impl<'a> Clone for Utf8Chunk<'a>

1.79.0 · Source§

impl<'a> Clone for Utf8Chunks<'a>

Source§

impl<'a> Clone for Utf8Pattern<'a>

Source§

impl<'a> Clone for Wtf8CodePoints<'a>

Source§

impl<'f> Clone for VaList<'f>

1.63.0 · Source§

impl<'fd> Clone for BorrowedFd<'fd>

Available on Hermit or Motor OS or Trusty or Unix or WASI only.
1.0.0 · Source§

impl<A, B> Clone for Chain<A, B>
where A: Clone, B: Clone,

1.0.0 · Source§

impl<A, B> Clone for Zip<A, B>
where A: Clone, B: Clone,

1.0.0 · Source§

impl<A> Clone for std::option::IntoIter<A>
where A: Clone,

1.0.0 · Source§

impl<A> Clone for std::option::Iter<'_, A>

Source§

impl<A> Clone for OptionFlatten<A>
where A: Clone,

1.96.0 · Source§

impl<A> Clone for RangeFromIter<A>
where A: Clone,

1.95.0 · Source§

impl<A> Clone for RangeInclusiveIter<A>
where A: Clone,

1.96.0 · Source§

impl<A> Clone for RangeIter<A>
where A: Clone,

1.0.0 · Source§

impl<A> Clone for Repeat<A>
where A: Clone,

1.82.0 · Source§

impl<A> Clone for RepeatN<A>
where A: Clone,

1.55.0 (const: unstable) · Source§

impl<B, C> Clone for ControlFlow<B, C>
where B: Clone, C: Clone,

1.0.0 · Source§

impl<B> Clone for Cow<'_, B>
where B: ToOwned + ?Sized,

Source§

impl<D: Clone> Clone for std::sys::thread_local::native::lazy::State<D>

Source§

impl<Dyn> Clone for DynMetadata<Dyn>
where Dyn: ?Sized,

1.34.0 · Source§

impl<F> Clone for FromFn<F>
where F: Clone,

1.43.0 · Source§

impl<F> Clone for OnceWith<F>
where F: Clone,

1.28.0 · Source§

impl<F> Clone for RepeatWith<F>
where F: Clone,

Source§

impl<G> Clone for FromCoroutine<G>
where G: Clone,

1.7.0 · Source§

impl<H> Clone for BuildHasherDefault<H>

Source§

impl<I, F, const N: usize> Clone for MapWindows<I, F, N>
where I: Iterator + Clone, F: Clone, <I as Iterator>::Item: Clone,

1.0.0 · Source§

impl<I, F> Clone for FilterMap<I, F>
where I: Clone, F: Clone,

1.0.0 · Source§

impl<I, F> Clone for Inspect<I, F>
where I: Clone, F: Clone,

1.0.0 · Source§

impl<I, F> Clone for Map<I, F>
where I: Clone, F: Clone,

Source§

impl<I, G> Clone for IntersperseWith<I, G>
where I: Iterator + Clone, <I as Iterator>::Item: Clone, G: Clone,

1.0.0 · Source§

impl<I, P> Clone for Filter<I, P>
where I: Clone, P: Clone,

1.57.0 · Source§

impl<I, P> Clone for MapWhile<I, P>
where I: Clone, P: Clone,

1.0.0 · Source§

impl<I, P> Clone for SkipWhile<I, P>
where I: Clone, P: Clone,

1.0.0 · Source§

impl<I, P> Clone for TakeWhile<I, P>
where I: Clone, P: Clone,

1.0.0 · Source§

impl<I, St, F> Clone for Scan<I, St, F>
where I: Clone, St: Clone, F: Clone,

1.0.0 · Source§

impl<I, U, F> Clone for FlatMap<I, U, F>
where I: Clone, F: Clone, U: Clone + IntoIterator, <U as IntoIterator>::IntoIter: Clone,

1.29.0 · Source§

impl<I, U> Clone for Flatten<I>
where I: Clone + Iterator, <I as Iterator>::Item: IntoIterator<IntoIter = U, Item = <U as Iterator>::Item>, U: Clone + Iterator,

Source§

impl<I, const N: usize> Clone for ArrayChunks<I, N>
where I: Clone + Iterator, <I as Iterator>::Item: Clone,

1.1.0 · Source§

impl<I> Clone for Cloned<I>
where I: Clone,

1.36.0 · Source§

impl<I> Clone for Copied<I>
where I: Clone,

1.0.0 · Source§

impl<I> Clone for Cycle<I>
where I: Clone,

1.9.0 · Source§

impl<I> Clone for DecodeUtf16<I>
where I: Clone + Iterator<Item = u16>,

1.0.0 · Source§

impl<I> Clone for Enumerate<I>
where I: Clone,

Source§

impl<I> Clone for FromIter<I>
where I: Clone,

1.0.0 · Source§

impl<I> Clone for Fuse<I>
where I: Clone,

Source§

impl<I> Clone for Intersperse<I>
where I: Clone + Iterator, <I as Iterator>::Item: Clone,

1.0.0 · Source§

impl<I> Clone for Peekable<I>
where I: Clone + Iterator, <I as Iterator>::Item: Clone,

1.0.0 · Source§

impl<I> Clone for Skip<I>
where I: Clone,

1.28.0 · Source§

impl<I> Clone for StepBy<I>
where I: Clone,

1.0.0 · Source§

impl<I> Clone for Take<I>
where I: Clone,

1.0.0 (const: unstable) · Source§

impl<Idx> Clone for std::ops::Range<Idx>
where Idx: Clone,

1.96.0 (const: unstable) · Source§

impl<Idx> Clone for std::range::Range<Idx>
where Idx: Clone,

1.0.0 (const: unstable) · Source§

impl<Idx> Clone for std::ops::RangeFrom<Idx>
where Idx: Clone,

1.96.0 (const: unstable) · Source§

impl<Idx> Clone for std::range::RangeFrom<Idx>
where Idx: Clone,

1.26.0 · Source§

impl<Idx> Clone for std::ops::RangeInclusive<Idx>
where Idx: Clone,

1.95.0 · Source§

impl<Idx> Clone for std::range::RangeInclusive<Idx>
where Idx: Clone,

1.0.0 (const: unstable) · Source§

impl<Idx> Clone for RangeTo<Idx>
where Idx: Clone,

1.26.0 · Source§

impl<Idx> Clone for std::ops::RangeToInclusive<Idx>
where Idx: Clone,

1.96.0 · Source§

impl<Idx> Clone for std::range::RangeToInclusive<Idx>
where Idx: Clone,

1.0.0 · Source§

impl<K, V, A> Clone for BTreeMap<K, V, A>
where K: Clone, V: Clone, A: Allocator + Clone,

1.0.0 · Source§

impl<K, V, S, A> Clone for HashMap<K, V, S, A>
where K: Clone, V: Clone, S: Clone, A: Allocator + Clone,

Source§

impl<K, V> Clone for std::collections::btree_map::Cursor<'_, K, V>

1.0.0 · Source§

impl<K, V> Clone for std::collections::btree_map::Iter<'_, K, V>

1.0.0 · Source§

impl<K, V> Clone for std::collections::hash::map::Iter<'_, K, V>

1.0.0 · Source§

impl<K, V> Clone for std::collections::btree_map::Keys<'_, K, V>

1.0.0 · Source§

impl<K, V> Clone for std::collections::hash::map::Keys<'_, K, V>

1.17.0 · Source§

impl<K, V> Clone for std::collections::btree_map::Range<'_, K, V>

1.0.0 · Source§

impl<K, V> Clone for std::collections::btree_map::Values<'_, K, V>

1.0.0 · Source§

impl<K, V> Clone for std::collections::hash::map::Values<'_, K, V>

1.0.0 · Source§

impl<K> Clone for std::collections::hash::set::Iter<'_, K>

Source§

impl<P> Clone for MaybeDangling<P>
where P: Clone + ?Sized,

1.33.0 · Source§

impl<Ptr> Clone for Pin<Ptr>
where Ptr: Clone,

1.0.0 · Source§

impl<T, A> Clone for Arc<T, A>
where A: Allocator + Clone, T: ?Sized,

1.0.0 · Source§

impl<T, A> Clone for BTreeSet<T, A>
where T: Clone, A: Allocator + Clone,

1.0.0 · Source§

impl<T, A> Clone for BinaryHeap<T, A>
where T: Clone, A: Allocator + Clone,

1.0.0 · Source§

impl<T, A> Clone for Box<T, A>
where T: Clone, A: Allocator + Clone,

1.3.0 · Source§

impl<T, A> Clone for Box<[T], A>
where T: Clone, A: Allocator + Clone,

Source§

impl<T, A> Clone for std::collections::linked_list::Cursor<'_, T, A>
where A: Allocator,

1.0.0 · Source§

impl<T, A> Clone for std::collections::btree_set::Difference<'_, T, A>
where A: Allocator + Clone,

1.0.0 · Source§

impl<T, A> Clone for std::collections::btree_set::Intersection<'_, T, A>
where A: Allocator + Clone,

1.8.0 · Source§

impl<T, A> Clone for std::vec::IntoIter<T, A>
where T: Clone, A: Allocator + Clone,

1.0.0 · Source§

impl<T, A> Clone for std::collections::binary_heap::IntoIter<T, A>
where T: Clone, A: Clone + Allocator,

1.0.0 · Source§

impl<T, A> Clone for std::collections::linked_list::IntoIter<T, A>
where T: Clone, A: Clone + Allocator,

1.0.0 · Source§

impl<T, A> Clone for std::collections::vec_deque::IntoIter<T, A>
where T: Clone, A: Clone + Allocator,

Source§

impl<T, A> Clone for IntoIterSorted<T, A>
where T: Clone, A: Clone + Allocator,

1.0.0 · Source§

impl<T, A> Clone for LinkedList<T, A>
where T: Clone, A: Allocator + Clone,

1.0.0 · Source§

impl<T, A> Clone for Rc<T, A>
where A: Allocator + Clone, T: ?Sized,

1.0.0 · Source§

impl<T, A> Clone for Vec<T, A>
where T: Clone, A: Allocator + Clone,

1.0.0 · Source§

impl<T, A> Clone for VecDeque<T, A>
where T: Clone, A: Allocator + Clone,

1.4.0 · Source§

impl<T, A> Clone for std::rc::Weak<T, A>
where A: Allocator + Clone, T: ?Sized,

1.4.0 · Source§

impl<T, A> Clone for std::sync::Weak<T, A>
where A: Allocator + Clone, T: ?Sized,

1.0.0 · Source§

impl<T, E> Clone for Result<T, E>
where T: Clone, E: Clone,

1.34.0 · Source§

impl<T, F> Clone for Successors<T, F>
where T: Clone, F: Clone,

1.27.0 · Source§

impl<T, P> Clone for std::slice::RSplit<'_, T, P>
where P: Clone + FnMut(&T) -> bool,

1.0.0 · Source§

impl<T, P> Clone for std::slice::Split<'_, T, P>
where P: Clone + FnMut(&T) -> bool,

1.51.0 · Source§

impl<T, P> Clone for std::slice::SplitInclusive<'_, T, P>
where P: Clone + FnMut(&T) -> bool,

1.0.0 · Source§

impl<T, S, A: Allocator> Clone for std::collections::hash::set::Difference<'_, T, S, A>

1.0.0 · Source§

impl<T, S, A: Allocator> Clone for std::collections::hash::set::Intersection<'_, T, S, A>

1.0.0 · Source§

impl<T, S, A: Allocator> Clone for std::collections::hash::set::SymmetricDifference<'_, T, S, A>

1.0.0 · Source§

impl<T, S, A: Allocator> Clone for std::collections::hash::set::Union<'_, T, S, A>

1.0.0 · Source§

impl<T, S, A> Clone for HashSet<T, S, A>
where T: Clone, S: Clone, A: Allocator + Clone,

1.99.0 · Source§

impl<T, const N: usize, A> Clone for BoxedArrayIntoIter<T, N, A>
where T: Clone, A: Clone + Allocator,

1.94.0 · Source§

impl<T, const N: usize> Clone for ArrayWindows<'_, T, N>

1.51.0 · Source§

impl<T, const N: usize> Clone for std::array::IntoIter<T, N>
where T: Clone,

Source§

impl<T, const N: usize> Clone for Mask<T, N>
where T: MaskElement,

Source§

impl<T, const N: usize> Clone for Simd<T, N>
where T: SimdElement,

1.58.0 · Source§

impl<T, const N: usize> Clone for [T; N]
where T: Clone,

Source§

impl<T, const VARIANT: u32, const FIELD: u32> Clone for FieldRepresentingType<T, VARIANT, FIELD>
where T: ?Sized,

Source§

impl<T: Clone> Clone for CachePadded<T>

1.70.0 · Source§

impl<T: Clone> Clone for OnceLock<T>

1.0.0 · Source§

impl<T: Clone> Clone for SendError<T>

Source§

impl<T: Clone> Clone for SendTimeoutError<T>

1.0.0 · Source§

impl<T: Clone> Clone for TrySendError<T>

1.0.0 · Source§

impl<T> !Clone for &mut T
where T: ?Sized,

Shared references can be cloned, but mutable references cannot!

1.0.0 (const: unstable) · Source§

impl<T> Clone for &T
where T: ?Sized,

Shared references can be cloned, but mutable references cannot!

1.0.0 (const: unstable) · Source§

impl<T> Clone for *const T
where T: ?Sized,

1.0.0 (const: unstable) · Source§

impl<T> Clone for *mut T
where T: ?Sized,

1.17.0 (const: unstable) · Source§

impl<T> Clone for Bound<T>
where T: Clone,

1.0.0 · Source§

impl<T> Clone for Cell<T>
where T: Copy,

1.0.0 · Source§

impl<T> Clone for Chunks<'_, T>

1.31.0 · Source§

impl<T> Clone for ChunksExact<'_, T>

1.0.0 · Source§

impl<T> Clone for std::io::Cursor<T>
where T: Clone,

1.21.0 · Source§

impl<T> Clone for Discriminant<T>

1.2.0 · Source§

impl<T> Clone for std::iter::Empty<T>

1.0.0 · Source§

impl<T> Clone for std::result::IntoIter<T>
where T: Clone,

1.0.0 · Source§

impl<T> Clone for std::result::Iter<'_, T>

1.0.0 · Source§

impl<T> Clone for std::slice::Iter<'_, T>

1.0.0 · Source§

impl<T> Clone for std::collections::binary_heap::Iter<'_, T>

1.0.0 · Source§

impl<T> Clone for std::collections::btree_set::Iter<'_, T>

1.0.0 · Source§

impl<T> Clone for std::collections::linked_list::Iter<'_, T>

1.0.0 · Source§

impl<T> Clone for std::collections::vec_deque::Iter<'_, T>

1.20.0 · Source§

impl<T> Clone for ManuallyDrop<T>
where T: Clone + ?Sized,

1.36.0 · Source§

impl<T> Clone for MaybeUninit<T>
where T: Copy,

1.25.0 · Source§

impl<T> Clone for NonNull<T>
where T: ?Sized,

1.28.0 (const: unstable) · Source§

impl<T> Clone for NonZero<T>

1.2.0 · Source§

impl<T> Clone for Once<T>
where T: Clone,

1.70.0 · Source§

impl<T> Clone for OnceCell<T>
where T: Clone,

1.0.0 (const: unstable) · Source§

impl<T> Clone for Option<T>
where T: Clone,

1.48.0 · Source§

impl<T> Clone for Pending<T>

Source§

impl<T> Clone for PhantomContravariant<T>
where T: ?Sized,

Source§

impl<T> Clone for PhantomCovariant<T>
where T: ?Sized,

1.0.0 · Source§

impl<T> Clone for PhantomData<T>
where T: ?Sized,

Source§

impl<T> Clone for PhantomInvariant<T>
where T: ?Sized,

1.36.0 · Source§

impl<T> Clone for Poll<T>
where T: Clone,

1.31.0 · Source§

impl<T> Clone for RChunks<'_, T>

1.17.0 · Source§

impl<T> Clone for std::collections::btree_set::Range<'_, T>

1.48.0 · Source§

impl<T> Clone for Ready<T>
where T: Clone,

Source§

impl<T> Clone for Receiver<T>

1.0.0 · Source§

impl<T> Clone for RefCell<T>
where T: Clone,

1.0.0 · Source§

impl<T> Clone for Rev<T>
where T: Clone,

1.19.0 · Source§

impl<T> Clone for Reverse<T>
where T: Clone,

1.74.0 · Source§

impl<T> Clone for Saturating<T>
where T: Clone,

Source§

impl<T> Clone for std::sync::mpmc::Sender<T>

1.0.0 · Source§

impl<T> Clone for std::sync::mpsc::Sender<T>

1.0.0 · Source§

impl<T> Clone for std::collections::btree_set::SymmetricDifference<'_, T>

1.0.0 · Source§

impl<T> Clone for SyncSender<T>

Source§

impl<T> Clone for SyncView<T>
where T: Sync + Clone,

1.0.0 · Source§

impl<T> Clone for std::collections::btree_set::Union<'_, T>

Source§

impl<T> Clone for Unique<T>
where T: ?Sized,

1.0.0 · Source§

impl<T> Clone for Windows<'_, T>

1.0.0 · Source§

impl<T> Clone for Wrapping<T>
where T: Clone,

Source§

impl<Y, R> Clone for CoroutineState<Y, R>
where Y: Clone, R: Clone,