Skip to content

Commit 501ab4e

Browse files
committed
Clarify Share trait docs
1 parent c01e320 commit 501ab4e

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

library/core/src/clone.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -290,21 +290,23 @@ pub macro Clone($item:item) {
290290
/* compiler built-in */
291291
}
292292

293-
/// A trait for types whose [`Clone`] operation creates another alias to the same value.
294-
///
295-
/// `Share` marks types where cloning creates another handle or reference to the same logical
296-
/// resource or shared state, rather than an independent owned value. The distinction is semantic,
297-
/// not cost-based: implementing `Share` does not merely mean that cloning is cheap, constant-time,
298-
/// allocation-free, or convenient.
299-
///
300-
/// Calling [`share`](Share::share) is equivalent to calling [`clone`](Clone::clone) for
301-
/// implementors, but communicates that the resulting value aliases the same underlying resource.
302-
///
303-
/// Shared references, [`Rc`](std::rc::Rc), [`Arc`](std::sync::Arc),
304-
/// [`Sender`](std::sync::mpsc::Sender), and [`SyncSender`](std::sync::mpsc::SyncSender) are
305-
/// examples of types that can be shared this way. Types such as [`Vec`](std::vec::Vec),
306-
/// [`String`](std::string::String), and [`Box`](std::boxed::Box) are not `Share` even though they
307-
/// implement `Clone`, because cloning them creates another owned value rather than another handle
293+
/// A trait for types whose [`Clone`] operation creates another alias to the same
294+
/// logical resource or shared state.
295+
///
296+
/// `Share` marks types where cloning creates another handle, reference, or alias
297+
/// to the same logical resource or shared state, rather than an independent owned
298+
/// value. The distinction is semantic, not cost-based: implementing `Share` does
299+
/// not merely mean that cloning is cheap, constant-time, allocation-free, or
300+
/// convenient.
301+
///
302+
/// Calling [`share`](Share::share) is equivalent to calling [`clone`](Clone::clone)
303+
/// for implementors, but communicates that the resulting value aliases the same
304+
/// underlying resource.
305+
///
306+
/// Shared references, `Rc<T>`, `Arc<T>`, `Sender<T>`, and `SyncSender<T>` are
307+
/// examples of types that can be shared this way. Types such as `Vec<T>`,
308+
/// `String`, and `Box<T>` are not `Share` even though they implement `Clone`,
309+
/// because cloning them creates another owned value rather than another handle
308310
/// to the same logical resource.
309311
///
310312
/// # Examples
@@ -363,7 +365,7 @@ pub macro Clone($item:item) {
363365
/// ```
364366
#[unstable(feature = "share_trait", issue = "156756")]
365367
pub trait Share: Clone {
366-
/// Creates another alias to the same underlying value.
368+
/// Creates another alias to the same underlying resource or shared state.
367369
///
368370
/// This is equivalent to calling [`Clone::clone`].
369371
#[unstable(feature = "share_trait", issue = "156756")]

0 commit comments

Comments
 (0)