diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-05-26 10:20:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-26 10:20:29 -0400 |
| commit | 854196a0eda59d9e8bd90c943dd4df275ff2b2f2 (patch) | |
| tree | 1d759fb7b191c5d1dcc582d36036d23e542ebce0 | |
| parent | 2c3aa9154d5abb7a2db15c878de2b07468bcf2af (diff) | |
| parent | bbf1dc4fad3389073cdb27fd1c291df469628735 (diff) | |
Rollup merge of #42236 - citizen428:docs/unchecked-indexing-slicing, r=GuillaumeGomez
Update documentation for indexing/slicing methods See #39911 r? @steveklabnik
| -rw-r--r-- | src/libcollections/slice.rs | 14 | ||||
| -rw-r--r-- | src/libcollections/str.rs | 11 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 5696f5fe6a7..233ff8a5154 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -393,7 +393,12 @@ impl<T> [T] { } /// Returns a reference to an element or subslice, without doing bounds - /// checking. So use it very carefully! + /// checking. + /// + /// This is generally not recommended, use with caution! For a safe + /// alternative see [`get`]. + /// + /// [`get`]: #method.get /// /// # Examples /// @@ -413,7 +418,12 @@ impl<T> [T] { } /// Returns a mutable reference to an element or subslice, without doing - /// bounds checking. So use it very carefully! + /// bounds checking. + /// + /// This is generally not recommended, use with caution! For a safe + /// alternative see [`get_mut`]. + /// + /// [`get_mut`]: #method.get_mut /// /// # Examples /// diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 3ea2050619b..eb32f478194 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -435,6 +435,12 @@ impl str { /// Creates a string slice from another string slice, bypassing safety /// checks. /// + /// This is generally not recommended, use with caution! For a safe + /// alternative see [`str`] and [`Index`]. + /// + /// [`str`]: primitive.str.html + /// [`Index`]: ops/trait.Index.html + /// /// This new slice goes from `begin` to `end`, including `begin` but /// excluding `end`. /// @@ -477,6 +483,11 @@ impl str { /// Creates a string slice from another string slice, bypassing safety /// checks. + /// This is generally not recommended, use with caution! For a safe + /// alternative see [`str`] and [`IndexMut`]. + /// + /// [`str`]: primitive.str.html + /// [`IndexMut`]: ops/trait.IndexMut.html /// /// This new slice goes from `begin` to `end`, including `begin` but /// excluding `end`. |
