Skip to content

Commit 892be3f

Browse files
committed
Auto merge of #41784 - frewsxcv:slice-clone-copy-links, r=GuillaumeGomez
Add links between `slice::{copy,clone}_from_slice` in docs. None
2 parents 0c2f34d + 65e56fa commit 892be3f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcollections/slice.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,9 @@ impl<T> [T] {
13411341
///
13421342
/// The length of `src` must be the same as `self`.
13431343
///
1344+
/// If `src` implements `Copy`, it can be more performant to use
1345+
/// [`copy_from_slice`].
1346+
///
13441347
/// # Panics
13451348
///
13461349
/// This function will panic if the two slices have different lengths.
@@ -1354,6 +1357,8 @@ impl<T> [T] {
13541357
/// dst.clone_from_slice(&src);
13551358
/// assert!(dst == [1, 2, 3]);
13561359
/// ```
1360+
///
1361+
/// [`copy_from_slice`]: #method.copy_from_slice
13571362
#[stable(feature = "clone_from_slice", since = "1.7.0")]
13581363
pub fn clone_from_slice(&mut self, src: &[T]) where T: Clone {
13591364
core_slice::SliceExt::clone_from_slice(self, src)
@@ -1363,6 +1368,8 @@ impl<T> [T] {
13631368
///
13641369
/// The length of `src` must be the same as `self`.
13651370
///
1371+
/// If `src` does not implement `Copy`, use [`clone_from_slice`].
1372+
///
13661373
/// # Panics
13671374
///
13681375
/// This function will panic if the two slices have different lengths.
@@ -1376,6 +1383,8 @@ impl<T> [T] {
13761383
/// dst.copy_from_slice(&src);
13771384
/// assert_eq!(src, dst);
13781385
/// ```
1386+
///
1387+
/// [`clone_from_slice`]: #method.clone_from_slice
13791388
#[stable(feature = "copy_from_slice", since = "1.9.0")]
13801389
pub fn copy_from_slice(&mut self, src: &[T]) where T: Copy {
13811390
core_slice::SliceExt::copy_from_slice(self, src)

0 commit comments

Comments
 (0)