Skip to content

Commit 13c5f60

Browse files
Rollup merge of rust-lang#51701 - anirudhb:master, r=frewsxcv
Better docs for copy_from_slice & clone_from_slice I copy-pasted the text from clone_from_slice to copy_from_slice 😄 @steveklabnik feel free to suggest changes. edit: closes rust-lang#49769
2 parents 4700e11 + 4b51484 commit 13c5f60

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libcore/slice/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,9 @@ impl<T> [T] {
15411541
/// let src = [1, 2, 3, 4];
15421542
/// let mut dst = [0, 0];
15431543
///
1544+
/// // Because the slices have to be the same length,
1545+
/// // we slice the source slice from four elements
1546+
/// // to two. It will panic if we don't do this.
15441547
/// dst.clone_from_slice(&src[2..]);
15451548
///
15461549
/// assert_eq!(src, [1, 2, 3, 4]);
@@ -1607,6 +1610,9 @@ impl<T> [T] {
16071610
/// let src = [1, 2, 3, 4];
16081611
/// let mut dst = [0, 0];
16091612
///
1613+
/// // Because the slices have to be the same length,
1614+
/// // we slice the source slice from four elements
1615+
/// // to two. It will panic if we don't do this.
16101616
/// dst.copy_from_slice(&src[2..]);
16111617
///
16121618
/// assert_eq!(src, [1, 2, 3, 4]);

0 commit comments

Comments
 (0)