Skip to content

core: Update clone docs #6528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ by convention implementing the `Clone` trait and calling the
use core::kinds::Const;

pub trait Clone {
/// Return a deep copy of the owned object tree. Types with shared ownership like managed boxes
/// are cloned with a shallow copy.
/// Returns a copy of the value. The contents of owned pointers
/// are copied to maintain uniqueness, while the contents of
/// managed pointers are not copied.
fn clone(&self) -> Self;
}

Expand Down Expand Up @@ -85,8 +86,9 @@ clone_impl!(bool)
clone_impl!(char)

pub trait DeepClone {
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
/// deep copy, unlike `Clone`.
/// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
/// *are* copied. Note that this is currently unimplemented for managed boxes, as
/// it would need to handle cycles, but it is implemented for other smart-pointer types.
fn deep_clone(&self) -> Self;
}

Expand Down