Skip to content

Commit

Permalink
cleanup trait bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Dec 9, 2024
1 parent d34284c commit 987c371
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
7 changes: 3 additions & 4 deletions crossbeam-skiplist/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use super::Comparable;
use alloc::alloc::{alloc, dealloc, handle_alloc_error, Layout};
use core::borrow::Borrow;
use core::cmp;
use core::fmt;
use core::marker::PhantomData;
Expand Down Expand Up @@ -746,11 +745,11 @@ where
// bound, we return the last node before the condition became true. For the
// lower bound, we return the first node after the condition became true.
if upper_bound {
if !below_upper_bound(&bound, c.key.borrow()) {
if !below_upper_bound(&bound, &c.key) {
break;
}
result = Some(c);
} else if above_lower_bound(&bound, c.key.borrow()) {
} else if above_lower_bound(&bound, &c.key) {
result = Some(c);
break;
}
Expand Down Expand Up @@ -1870,7 +1869,7 @@ where
if let Some(t) = self.tail {
match self.head {
Some(h) => {
let bound = Bound::Excluded(h.key.borrow());
let bound = Bound::Excluded(&h.key);
if !above_lower_bound(&bound, &t.key) {
self.head = None;
self.tail = None;
Expand Down
15 changes: 5 additions & 10 deletions crossbeam-skiplist/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,19 +721,17 @@ impl<K, V> Drop for Iter<'_, K, V> {
/// An iterator over a subset of entries of a `SkipMap`.
pub struct Range<'a, Q, R, K, V>
where
K: Ord,
K: Ord + Comparable<Q>,
R: RangeBounds<Q>,
K: Comparable<Q>,
Q: ?Sized,
{
pub(crate) inner: base::RefRange<'a, Q, R, K, V>,
}

impl<'a, Q, R, K, V> Iterator for Range<'a, Q, R, K, V>
where
K: Ord,
K: Ord + Comparable<Q>,
R: RangeBounds<Q>,
K: Comparable<Q>,
Q: ?Sized,
{
type Item = Entry<'a, K, V>;
Expand All @@ -746,9 +744,8 @@ where

impl<'a, Q, R, K, V> DoubleEndedIterator for Range<'a, Q, R, K, V>
where
K: Ord,
K: Ord + Comparable<Q>,
R: RangeBounds<Q>,
K: Comparable<Q>,
Q: ?Sized,
{
fn next_back(&mut self) -> Option<Entry<'a, K, V>> {
Expand All @@ -759,10 +756,9 @@ where

impl<Q, R, K, V> fmt::Debug for Range<'_, Q, R, K, V>
where
K: Ord + fmt::Debug,
K: Ord + fmt::Debug + Comparable<Q>,
V: fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
K: Comparable<Q>,
Q: ?Sized,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -776,9 +772,8 @@ where

impl<Q, R, K, V> Drop for Range<'_, Q, R, K, V>
where
K: Ord,
K: Ord + Comparable<Q>,
R: RangeBounds<Q>,
K: Comparable<Q>,
Q: ?Sized,
{
fn drop(&mut self) {
Expand Down
13 changes: 4 additions & 9 deletions crossbeam-skiplist/src/set.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! A set based on a lock-free skip list. See [`SkipSet`].
use std::borrow::Borrow;
use std::fmt;
use std::ops::Deref;
use std::ops::{Bound, RangeBounds};
Expand Down Expand Up @@ -584,19 +583,17 @@ impl<T> fmt::Debug for Iter<'_, T> {
/// An iterator over a subset of entries of a `SkipSet`.
pub struct Range<'a, Q, R, T>
where
T: Ord,
T: Ord + Comparable<Q>,
R: RangeBounds<Q>,
T: Comparable<Q>,
Q: ?Sized,
{
inner: map::Range<'a, Q, R, T, ()>,
}

impl<'a, Q, R, T> Iterator for Range<'a, Q, R, T>
where
T: Ord,
T: Ord + Comparable<Q>,
R: RangeBounds<Q>,
T: Comparable<Q>,
Q: ?Sized,
{
type Item = Entry<'a, T>;
Expand All @@ -608,9 +605,8 @@ where

impl<'a, Q, R, T> DoubleEndedIterator for Range<'a, Q, R, T>
where
T: Ord + Borrow<Q>,
T: Ord + Comparable<Q>,
R: RangeBounds<Q>,
T: Comparable<Q>,
Q: ?Sized,
{
fn next_back(&mut self) -> Option<Entry<'a, T>> {
Expand All @@ -620,9 +616,8 @@ where

impl<Q, R, T> fmt::Debug for Range<'_, Q, R, T>
where
T: Ord + Borrow<Q> + fmt::Debug,
T: Ord + Comparable<Q> + fmt::Debug,
R: RangeBounds<Q> + fmt::Debug,
T: Comparable<Q>,
Q: ?Sized,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit 987c371

Please sign in to comment.