@@ -1541,6 +1541,10 @@ impl<T> [T] {
1541
1541
/// let src = [1, 2, 3, 4];
1542
1542
/// let mut dst = [0, 0];
1543
1543
///
1544
+ /// // Note: the slices must be the same length, so
1545
+ /// // you can slice the source to be the same size.
1546
+ /// // Here we slice the source, four elements, to two, the same size
1547
+ /// // as the destination slice. It *will* panic if we don't do this.
1544
1548
/// dst.clone_from_slice(&src[2..]);
1545
1549
///
1546
1550
/// assert_eq!(src, [1, 2, 3, 4]);
@@ -1607,6 +1611,10 @@ impl<T> [T] {
1607
1611
/// let src = [1, 2, 3, 4];
1608
1612
/// let mut dst = [0, 0];
1609
1613
///
1614
+ /// // Note: the slices must be the same length, so
1615
+ /// // you can slice the source to be the same size.
1616
+ /// // Here we slice the source, four elements, to two, the same size
1617
+ /// // as the destination slice. It *will* panic if we don't do this.
1610
1618
/// dst.copy_from_slice(&src[2..]);
1611
1619
///
1612
1620
/// assert_eq!(src, [1, 2, 3, 4]);
0 commit comments