@@ -26,15 +26,15 @@ use hash::Hasher;
26
26
/// appropriate.
27
27
///
28
28
/// An example of a non-`Send` type is the reference-counting pointer
29
- /// [`rc::Rc`][rc ]. If two threads attempt to clone `Rc`s that point to the same
29
+ /// [`rc::Rc`][`Rc` ]. If two threads attempt to clone [ `Rc`] s that point to the same
30
30
/// reference-counted value, they might try to update the reference count at the
31
- /// same time, which is [undefined behavior][ub] because `Rc` doesn't use atomic
31
+ /// same time, which is [undefined behavior][ub] because [ `Rc`] doesn't use atomic
32
32
/// operations. Its cousin [`sync::Arc`][arc] does use atomic operations (incurring
33
33
/// some overhead) and thus is `Send`.
34
34
///
35
35
/// See [the Nomicon](../../nomicon/send-and-sync.html) for more details.
36
36
///
37
- /// [rc ]: ../../std/rc/struct.Rc.html
37
+ /// [`Rc` ]: ../../std/rc/struct.Rc.html
38
38
/// [arc]: ../../std/sync/struct.Arc.html
39
39
/// [ub]: ../../reference.html#behavior-considered-undefined
40
40
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -183,20 +183,17 @@ pub trait Unsize<T: ?Sized> {
183
183
/// Copies happen implicitly, for example as part of an assignment `y = x`. The behavior of
184
184
/// `Copy` is not overloadable; it is always a simple bit-wise copy.
185
185
///
186
- /// Cloning is an explicit action, `x.clone()`. The implementation of [`Clone`][clone] can
186
+ /// Cloning is an explicit action, `x.clone()`. The implementation of [`Clone`] can
187
187
/// provide any type-specific behavior necessary to duplicate values safely. For example,
188
- /// the implementation of `Clone` for [`String`][string ] needs to copy the pointed-to string
189
- /// buffer in the heap. A simple bitwise copy of `String` values would merely copy the
190
- /// pointer, leading to a double free down the line. For this reason, `String` is `Clone`
188
+ /// the implementation of [ `Clone`] for [`String`] needs to copy the pointed-to string
189
+ /// buffer in the heap. A simple bitwise copy of [ `String`] values would merely copy the
190
+ /// pointer, leading to a double free down the line. For this reason, [ `String`] is [ `Clone`]
191
191
/// but not `Copy`.
192
192
///
193
- /// `Clone` is a supertrait of `Copy`, so everything which is `Copy` must also implement
194
- /// `Clone`. If a type is `Copy` then its `Clone` implementation need only return `*self`
193
+ /// [ `Clone`] is a supertrait of `Copy`, so everything which is `Copy` must also implement
194
+ /// [ `Clone`] . If a type is `Copy` then its [ `Clone`] implementation need only return `*self`
195
195
/// (see the example above).
196
196
///
197
- /// [clone]: ../clone/trait.Clone.html
198
- /// [string]: ../../std/string/struct.String.html
199
- ///
200
197
/// ## When can my type be `Copy`?
201
198
///
202
199
/// A type can implement `Copy` if all of its components implement `Copy`. For example, this
@@ -210,7 +207,7 @@ pub trait Unsize<T: ?Sized> {
210
207
/// }
211
208
/// ```
212
209
///
213
- /// A struct can be `Copy`, and `i32` is `Copy`, therefore `Point` is eligible to be `Copy`.
210
+ /// A struct can be `Copy`, and [ `i32`] is `Copy`, therefore `Point` is eligible to be `Copy`.
214
211
/// By contrast, consider
215
212
///
216
213
/// ```
@@ -231,8 +228,8 @@ pub trait Unsize<T: ?Sized> {
231
228
/// ## When *can't* my type be `Copy`?
232
229
///
233
230
/// Some types can't be copied safely. For example, copying `&mut T` would create an aliased
234
- /// mutable reference. Copying [`String`] would duplicate responsibility for managing the `String`'s
235
- /// buffer, leading to a double free.
231
+ /// mutable reference. Copying [`String`] would duplicate responsibility for managing the
232
+ /// [`String`]'s buffer, leading to a double free.
236
233
///
237
234
/// Generalizing the latter case, any type implementing [`Drop`] can't be `Copy`, because it's
238
235
/// managing some resource besides its own [`size_of::<T>()`] bytes.
@@ -255,6 +252,9 @@ pub trait Unsize<T: ?Sized> {
255
252
/// [`String`]: ../../std/string/struct.String.html
256
253
/// [`Drop`]: ../../std/ops/trait.Drop.html
257
254
/// [`size_of::<T>()`]: ../../std/mem/fn.size_of.html
255
+ /// [`Clone`]: ../clone/trait.Clone.html
256
+ /// [`String`]: ../../std/string/struct.String.html
257
+ /// [`i32`]: ../../std/primitive.i32.html
258
258
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
259
259
#[ lang = "copy" ]
260
260
pub trait Copy : Clone {
@@ -290,20 +290,20 @@ pub trait Copy : Clone {
290
290
/// mutability" in a non-thread-safe form, such as [`cell::Cell`][cell]
291
291
/// and [`cell::RefCell`][refcell]. These types allow for mutation of
292
292
/// their contents even through an immutable, shared reference. For
293
- /// example the `set` method on `Cell<T>` takes `&self`, so it requires
294
- /// only a shared reference `&Cell<T>`. The method performs no
295
- /// synchronization, thus `Cell` cannot be `Sync`.
293
+ /// example the `set` method on [ `Cell<T>`][cell] takes `&self`, so it requires
294
+ /// only a shared reference [ `&Cell<T>`][cell] . The method performs no
295
+ /// synchronization, thus [ `Cell`][cell] cannot be `Sync`.
296
296
///
297
297
/// Another example of a non-`Sync` type is the reference-counting
298
- /// pointer [`rc::Rc`][rc]. Given any reference `&Rc<T>`, you can clone
299
- /// a new `Rc<T>`, modifying the reference counts in a non-atomic way.
298
+ /// pointer [`rc::Rc`][rc]. Given any reference [ `&Rc<T>`][rc] , you can clone
299
+ /// a new [ `Rc<T>`][rc] , modifying the reference counts in a non-atomic way.
300
300
///
301
301
/// For cases when one does need thread-safe interior mutability,
302
302
/// Rust provides [atomic data types], as well as explicit locking via
303
303
/// [`sync::Mutex`][mutex] and [`sync::RWLock`][rwlock]. These types
304
304
/// ensure that any mutation cannot cause data races, hence the types
305
305
/// are `Sync`. Likewise, [`sync::Arc`][arc] provides a thread-safe
306
- /// analogue of `Rc`.
306
+ /// analogue of [ `Rc`][rc] .
307
307
///
308
308
/// Any types with interior mutability must also use the
309
309
/// [`cell::UnsafeCell`][unsafecell] wrapper around the value(s) which
0 commit comments