From 7b4cbbd12d88c8e64d9c7aa1e326c7c78f2a7ed9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 28 Jan 2018 21:50:01 -0500 Subject: Document that `Index` ops can panic on `HashMap` & `BTreeMap`. Fixes https://github.com/rust-lang/rust/issues/47011. --- src/liballoc/btree/map.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/liballoc/btree') diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index b114dc640fb..b320bed5432 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -1748,6 +1748,11 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap { type Output = V; + /// Returns a reference to the value corresponding to the supplied key. + /// + /// # Panics + /// + /// Panics if the key is not present in the `BTreeMap`. #[inline] fn index(&self, key: &Q) -> &V { self.get(key).expect("no entry found for key") -- cgit 1.4.1-3-g733a5