diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-07-11 10:01:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-11 10:01:58 +0200 |
| commit | 13c5f606c6c734b0e9d233970fb5e306fb733754 (patch) | |
| tree | a9610c68bc56d547ef9b79f1443619674c4f363d /src/libcore/slice | |
| parent | 4700e1188f66fdb4086b7593416b678b8fe935f4 (diff) | |
| parent | 4b51484fed75750a84d8422d26a9a7e6c06294e0 (diff) | |
Rollup merge of #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 :smile: @steveklabnik feel free to suggest changes. edit: closes #49769
Diffstat (limited to 'src/libcore/slice')
| -rw-r--r-- | src/libcore/slice/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 87b7ae39cfd..ed29d80cb90 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1541,6 +1541,9 @@ impl<T> [T] { /// let src = [1, 2, 3, 4]; /// let mut dst = [0, 0]; /// + /// // Because the slices have to be the same length, + /// // we slice the source slice from four elements + /// // to two. It will panic if we don't do this. /// dst.clone_from_slice(&src[2..]); /// /// assert_eq!(src, [1, 2, 3, 4]); @@ -1607,6 +1610,9 @@ impl<T> [T] { /// let src = [1, 2, 3, 4]; /// let mut dst = [0, 0]; /// + /// // Because the slices have to be the same length, + /// // we slice the source slice from four elements + /// // to two. It will panic if we don't do this. /// dst.copy_from_slice(&src[2..]); /// /// assert_eq!(src, [1, 2, 3, 4]); |
