about summary refs log tree commit diff
diff options
context:
space:
mode:
authorr00ster <r00ster91@protonmail.com>2021-04-18 15:51:16 +0200
committerGitHub <noreply@github.com>2021-04-18 15:51:16 +0200
commitdf01b3a67b33ef0ff7ab1f27f41056093f5b2574 (patch)
tree5c05e31fc16d1854477036287b66b0564a19cc65
parentd7c338641466d54bf8d4b2eae5d6865483e1d3f4 (diff)
downloadrust-df01b3a67b33ef0ff7ab1f27f41056093f5b2574.tar.gz
rust-df01b3a67b33ef0ff7ab1f27f41056093f5b2574.zip
Document that `index` and `index_mut` can panic
-rw-r--r--library/core/src/ops/index.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs
index a8dea4e9b4e..515ccd6aa23 100644
--- a/library/core/src/ops/index.rs
+++ b/library/core/src/ops/index.rs
@@ -61,6 +61,10 @@ pub trait Index<Idx: ?Sized> {
     type Output: ?Sized;
 
     /// Performs the indexing (`container[index]`) operation.
+    ///
+    /// # Panics
+    ///
+    /// Panics if the index is out of bounds.
     #[stable(feature = "rust1", since = "1.0.0")]
     #[track_caller]
     fn index(&self, index: Idx) -> &Self::Output;
@@ -161,6 +165,10 @@ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#ind
 #[doc(alias = "[]")]
 pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
     /// Performs the mutable indexing (`container[index]`) operation.
+    ///
+    /// # Panics
+    ///
+    /// Panics if the index is out of bounds.
     #[stable(feature = "rust1", since = "1.0.0")]
     #[track_caller]
     fn index_mut(&mut self, index: Idx) -> &mut Self::Output;