Skip to content

Commit bbf1dc4

Browse files
committed
Update documentation for indexing/slicing methods
See #39911
1 parent 5b13bff commit bbf1dc4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/libcollections/slice.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,12 @@ impl<T> [T] {
393393
}
394394

395395
/// Returns a reference to an element or subslice, without doing bounds
396-
/// checking. So use it very carefully!
396+
/// checking.
397+
///
398+
/// This is generally not recommended, use with caution! For a safe
399+
/// alternative see [`get`].
400+
///
401+
/// [`get`]: #method.get
397402
///
398403
/// # Examples
399404
///
@@ -413,7 +418,12 @@ impl<T> [T] {
413418
}
414419

415420
/// Returns a mutable reference to an element or subslice, without doing
416-
/// bounds checking. So use it very carefully!
421+
/// bounds checking.
422+
///
423+
/// This is generally not recommended, use with caution! For a safe
424+
/// alternative see [`get_mut`].
425+
///
426+
/// [`get_mut`]: #method.get_mut
417427
///
418428
/// # Examples
419429
///

src/libcollections/str.rs

+11
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ impl str {
435435
/// Creates a string slice from another string slice, bypassing safety
436436
/// checks.
437437
///
438+
/// This is generally not recommended, use with caution! For a safe
439+
/// alternative see [`str`] and [`Index`].
440+
///
441+
/// [`str`]: primitive.str.html
442+
/// [`Index`]: ops/trait.Index.html
443+
///
438444
/// This new slice goes from `begin` to `end`, including `begin` but
439445
/// excluding `end`.
440446
///
@@ -477,6 +483,11 @@ impl str {
477483

478484
/// Creates a string slice from another string slice, bypassing safety
479485
/// checks.
486+
/// This is generally not recommended, use with caution! For a safe
487+
/// alternative see [`str`] and [`IndexMut`].
488+
///
489+
/// [`str`]: primitive.str.html
490+
/// [`IndexMut`]: ops/trait.IndexMut.html
480491
///
481492
/// This new slice goes from `begin` to `end`, including `begin` but
482493
/// excluding `end`.

0 commit comments

Comments
 (0)