Skip to content

Commit

Permalink
Document that Index ops can panic on HashMap & BTreeMap.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jan 29, 2018
1 parent 4a82c56 commit 5b63575
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,9 +1384,14 @@ impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap<K, V, S>
{
type Output = V;

/// Returns a reference to the value corresponding to the supplied key.
///
/// # Panics
///
/// Panics if the key is not present in the `HashMap`.
#[inline]
fn index(&self, index: &Q) -> &V {
self.get(index).expect("no entry found for key")
fn index(&self, key: &Q) -> &V {
self.get(key).expect("no entry found for key")
}
}

Expand Down

0 comments on commit 5b63575

Please sign in to comment.