Skip to content

Commit

Permalink
Fix mutability in doc tests for BTreeSet cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
kmicklas committed Aug 1, 2024
1 parent c7be27f commit 86ea79f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,16 +1250,16 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// let mut set = BTreeSet::from([1, 2, 3, 4]);
///
/// let mut cursor = set.lower_bound_mut(Bound::Included(&2));
/// assert_eq!(cursor.peek_prev(), Some(&mut 1));
/// assert_eq!(cursor.peek_next(), Some(&mut 2));
/// assert_eq!(cursor.peek_prev(), Some(&1));
/// assert_eq!(cursor.peek_next(), Some(&2));
///
/// let mut cursor = set.lower_bound_mut(Bound::Excluded(&2));
/// assert_eq!(cursor.peek_prev(), Some(&mut 2));
/// assert_eq!(cursor.peek_next(), Some(&mut 3));
/// assert_eq!(cursor.peek_prev(), Some(&2));
/// assert_eq!(cursor.peek_next(), Some(&3));
///
/// let mut cursor = set.lower_bound_mut(Bound::Unbounded);
/// assert_eq!(cursor.peek_prev(), None);
/// assert_eq!(cursor.peek_next(), Some(&mut 1));
/// assert_eq!(cursor.peek_next(), Some(&1));
/// ```
#[unstable(feature = "btree_cursors", issue = "107540")]
pub fn lower_bound_mut<Q: ?Sized>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, T, A>
Expand Down Expand Up @@ -1336,15 +1336,15 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// let mut set = BTreeSet::from([1, 2, 3, 4]);
///
/// let mut cursor = unsafe { set.upper_bound_mut(Bound::Included(&3)) };
/// assert_eq!(cursor.peek_prev(), Some(&mut 3));
/// assert_eq!(cursor.peek_next(), Some(&mut 4));
/// assert_eq!(cursor.peek_prev(), Some(&3));
/// assert_eq!(cursor.peek_next(), Some(&4));
///
/// let mut cursor = unsafe { set.upper_bound_mut(Bound::Excluded(&3)) };
/// assert_eq!(cursor.peek_prev(), Some(&mut 2));
/// assert_eq!(cursor.peek_next(), Some(&mut 3));
/// assert_eq!(cursor.peek_prev(), Some(&2));
/// assert_eq!(cursor.peek_next(), Some(&3));
///
/// let mut cursor = unsafe { set.upper_bound_mut(Bound::Unbounded) };
/// assert_eq!(cursor.peek_prev(), Some(&mut 4));
/// assert_eq!(cursor.peek_prev(), Some(&4));
/// assert_eq!(cursor.peek_next(), None);
/// ```
#[unstable(feature = "btree_cursors", issue = "107540")]
Expand Down

0 comments on commit 86ea79f

Please sign in to comment.