Skip to content

Commit e09eaaf

Browse files
committed
Document and track extract_if panics
1 parent a8d7dc5 commit e09eaaf

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

src/map.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ impl<K, V, S> IndexMap<K, V, S> {
325325
///
326326
/// [`retain`]: IndexMap::retain
327327
///
328+
/// ***Panics*** if the starting point is greater than the end point or if
329+
/// the end point is greater than the length of the map.
330+
///
328331
/// # Examples
329332
///
330333
/// Splitting a map into even and odd keys, reusing the original map:
@@ -341,6 +344,7 @@ impl<K, V, S> IndexMap<K, V, S> {
341344
/// assert_eq!(evens, vec![0, 2, 4, 6]);
342345
/// assert_eq!(odds, vec![1, 3, 5, 7]);
343346
/// ```
347+
#[track_caller]
344348
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, K, V, F>
345349
where
346350
F: FnMut(&K, &mut V) -> bool,

src/map/core/extract.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::util::simplify_range;
66
use core::ops::RangeBounds;
77

88
impl<K, V> IndexMapCore<K, V> {
9+
#[track_caller]
910
pub(crate) fn extract<R>(&mut self, range: R) -> ExtractCore<'_, K, V>
1011
where
1112
R: RangeBounds<usize>,

src/map/iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ pub struct ExtractIf<'a, K, V, F> {
784784
}
785785

786786
impl<K, V, F> ExtractIf<'_, K, V, F> {
787+
#[track_caller]
787788
pub(super) fn new<R>(core: &mut IndexMapCore<K, V>, range: R, pred: F) -> ExtractIf<'_, K, V, F>
788789
where
789790
R: RangeBounds<usize>,

src/set.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ impl<T, S> IndexSet<T, S> {
267267
///
268268
/// [`retain`]: IndexSet::retain
269269
///
270+
/// ***Panics*** if the starting point is greater than the end point or if
271+
/// the end point is greater than the length of the set.
272+
///
270273
/// # Examples
271274
///
272275
/// Splitting a set into even and odd values, reusing the original set:
@@ -283,6 +286,7 @@ impl<T, S> IndexSet<T, S> {
283286
/// assert_eq!(evens, vec![0, 2, 4, 6]);
284287
/// assert_eq!(odds, vec![1, 3, 5, 7]);
285288
/// ```
289+
#[track_caller]
286290
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, T, F>
287291
where
288292
F: FnMut(&T) -> bool,

src/set/iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ pub struct ExtractIf<'a, T, F> {
639639
}
640640

641641
impl<T, F> ExtractIf<'_, T, F> {
642+
#[track_caller]
642643
pub(super) fn new<R>(core: &mut IndexMapCore<T, ()>, range: R, pred: F) -> ExtractIf<'_, T, F>
643644
where
644645
R: RangeBounds<usize>,

0 commit comments

Comments
 (0)