Document that Index ops can panic on HashMap & BTreeMap.
Fixes https://github.com/rust-lang/rust/issues/47011.
This commit is contained in:
@@ -1748,6 +1748,11 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap<K, V>
|
||||
{
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user