Skip to content

Commit b76ff73

Browse files
committed
Fix clippy::multiple_bound_locations
1 parent 0060546 commit b76ff73

File tree

5 files changed

+70
-73
lines changed

5 files changed

+70
-73
lines changed

src/map.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ where
534534
/// Return `true` if an equivalent to `key` exists in the map.
535535
///
536536
/// Computes in **O(1)** time (average).
537-
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
537+
pub fn contains_key<Q>(&self, key: &Q) -> bool
538538
where
539-
Q: Hash + Equivalent<K>,
539+
Q: ?Sized + Hash + Equivalent<K>,
540540
{
541541
self.get_index_of(key).is_some()
542542
}
@@ -545,9 +545,9 @@ where
545545
/// else `None`.
546546
///
547547
/// Computes in **O(1)** time (average).
548-
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
548+
pub fn get<Q>(&self, key: &Q) -> Option<&V>
549549
where
550-
Q: Hash + Equivalent<K>,
550+
Q: ?Sized + Hash + Equivalent<K>,
551551
{
552552
if let Some(i) = self.get_index_of(key) {
553553
let entry = &self.as_entries()[i];
@@ -561,9 +561,9 @@ where
561561
/// if it is present, else `None`.
562562
///
563563
/// Computes in **O(1)** time (average).
564-
pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)>
564+
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
565565
where
566-
Q: Hash + Equivalent<K>,
566+
Q: ?Sized + Hash + Equivalent<K>,
567567
{
568568
if let Some(i) = self.get_index_of(key) {
569569
let entry = &self.as_entries()[i];
@@ -574,9 +574,9 @@ where
574574
}
575575

576576
/// Return item index, key and value
577-
pub fn get_full<Q: ?Sized>(&self, key: &Q) -> Option<(usize, &K, &V)>
577+
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
578578
where
579-
Q: Hash + Equivalent<K>,
579+
Q: ?Sized + Hash + Equivalent<K>,
580580
{
581581
if let Some(i) = self.get_index_of(key) {
582582
let entry = &self.as_entries()[i];
@@ -589,9 +589,9 @@ where
589589
/// Return item index, if it exists in the map
590590
///
591591
/// Computes in **O(1)** time (average).
592-
pub fn get_index_of<Q: ?Sized>(&self, key: &Q) -> Option<usize>
592+
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
593593
where
594-
Q: Hash + Equivalent<K>,
594+
Q: ?Sized + Hash + Equivalent<K>,
595595
{
596596
match self.as_entries() {
597597
[] => None,
@@ -603,9 +603,9 @@ where
603603
}
604604
}
605605

606-
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V>
606+
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
607607
where
608-
Q: Hash + Equivalent<K>,
608+
Q: ?Sized + Hash + Equivalent<K>,
609609
{
610610
if let Some(i) = self.get_index_of(key) {
611611
let entry = &mut self.as_entries_mut()[i];
@@ -615,9 +615,9 @@ where
615615
}
616616
}
617617

618-
pub fn get_full_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<(usize, &K, &mut V)>
618+
pub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(usize, &K, &mut V)>
619619
where
620-
Q: Hash + Equivalent<K>,
620+
Q: ?Sized + Hash + Equivalent<K>,
621621
{
622622
if let Some(i) = self.get_index_of(key) {
623623
let entry = &mut self.as_entries_mut()[i];
@@ -636,9 +636,9 @@ where
636636
/// [`.shift_remove(key)`][Self::shift_remove] instead.
637637
#[deprecated(note = "`remove` disrupts the map order -- \
638638
use `swap_remove` or `shift_remove` for explicit behavior.")]
639-
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
639+
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
640640
where
641-
Q: Hash + Equivalent<K>,
641+
Q: ?Sized + Hash + Equivalent<K>,
642642
{
643643
self.swap_remove(key)
644644
}
@@ -651,9 +651,9 @@ where
651651
/// use [`.shift_remove_entry(key)`][Self::shift_remove_entry] instead.
652652
#[deprecated(note = "`remove_entry` disrupts the map order -- \
653653
use `swap_remove_entry` or `shift_remove_entry` for explicit behavior.")]
654-
pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>
654+
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
655655
where
656-
Q: Hash + Equivalent<K>,
656+
Q: ?Sized + Hash + Equivalent<K>,
657657
{
658658
self.swap_remove_entry(key)
659659
}
@@ -668,9 +668,9 @@ where
668668
/// Return `None` if `key` is not in map.
669669
///
670670
/// Computes in **O(1)** time (average).
671-
pub fn swap_remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
671+
pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
672672
where
673-
Q: Hash + Equivalent<K>,
673+
Q: ?Sized + Hash + Equivalent<K>,
674674
{
675675
self.swap_remove_full(key).map(third)
676676
}
@@ -684,9 +684,9 @@ where
684684
/// Return `None` if `key` is not in map.
685685
///
686686
/// Computes in **O(1)** time (average).
687-
pub fn swap_remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>
687+
pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
688688
where
689-
Q: Hash + Equivalent<K>,
689+
Q: ?Sized + Hash + Equivalent<K>,
690690
{
691691
match self.swap_remove_full(key) {
692692
Some((_, key, value)) => Some((key, value)),
@@ -704,9 +704,9 @@ where
704704
/// Return `None` if `key` is not in map.
705705
///
706706
/// Computes in **O(1)** time (average).
707-
pub fn swap_remove_full<Q: ?Sized>(&mut self, key: &Q) -> Option<(usize, K, V)>
707+
pub fn swap_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
708708
where
709-
Q: Hash + Equivalent<K>,
709+
Q: ?Sized + Hash + Equivalent<K>,
710710
{
711711
match self.as_entries() {
712712
[x] if key.equivalent(&x.key) => {
@@ -731,9 +731,9 @@ where
731731
/// Return `None` if `key` is not in map.
732732
///
733733
/// Computes in **O(n)** time (average).
734-
pub fn shift_remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
734+
pub fn shift_remove<Q>(&mut self, key: &Q) -> Option<V>
735735
where
736-
Q: Hash + Equivalent<K>,
736+
Q: ?Sized + Hash + Equivalent<K>,
737737
{
738738
self.shift_remove_full(key).map(third)
739739
}
@@ -747,9 +747,9 @@ where
747747
/// Return `None` if `key` is not in map.
748748
///
749749
/// Computes in **O(n)** time (average).
750-
pub fn shift_remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>
750+
pub fn shift_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
751751
where
752-
Q: Hash + Equivalent<K>,
752+
Q: ?Sized + Hash + Equivalent<K>,
753753
{
754754
match self.shift_remove_full(key) {
755755
Some((_, key, value)) => Some((key, value)),
@@ -767,9 +767,9 @@ where
767767
/// Return `None` if `key` is not in map.
768768
///
769769
/// Computes in **O(n)** time (average).
770-
pub fn shift_remove_full<Q: ?Sized>(&mut self, key: &Q) -> Option<(usize, K, V)>
770+
pub fn shift_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
771771
where
772-
Q: Hash + Equivalent<K>,
772+
Q: ?Sized + Hash + Equivalent<K>,
773773
{
774774
match self.as_entries() {
775775
[x] if key.equivalent(&x.key) => {

src/map/core/raw_entry_v1.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,18 @@ impl<K, V, S> fmt::Debug for RawEntryBuilder<'_, K, V, S> {
198198

199199
impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> {
200200
/// Access an entry by key.
201-
pub fn from_key<Q: ?Sized>(self, key: &Q) -> Option<(&'a K, &'a V)>
201+
pub fn from_key<Q>(self, key: &Q) -> Option<(&'a K, &'a V)>
202202
where
203203
S: BuildHasher,
204-
Q: Hash + Equivalent<K>,
204+
Q: ?Sized + Hash + Equivalent<K>,
205205
{
206206
self.map.get_key_value(key)
207207
}
208208

209209
/// Access an entry by a key and its hash.
210-
pub fn from_key_hashed_nocheck<Q: ?Sized>(self, hash: u64, key: &Q) -> Option<(&'a K, &'a V)>
210+
pub fn from_key_hashed_nocheck<Q>(self, hash: u64, key: &Q) -> Option<(&'a K, &'a V)>
211211
where
212-
Q: Equivalent<K>,
212+
Q: ?Sized + Equivalent<K>,
213213
{
214214
let hash = HashValue(hash as usize);
215215
let i = self.map.core.get_index_of(hash, key)?;
@@ -265,19 +265,19 @@ impl<K, V, S> fmt::Debug for RawEntryBuilderMut<'_, K, V, S> {
265265

266266
impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> {
267267
/// Access an entry by key.
268-
pub fn from_key<Q: ?Sized>(self, key: &Q) -> RawEntryMut<'a, K, V, S>
268+
pub fn from_key<Q>(self, key: &Q) -> RawEntryMut<'a, K, V, S>
269269
where
270270
S: BuildHasher,
271-
Q: Hash + Equivalent<K>,
271+
Q: ?Sized + Hash + Equivalent<K>,
272272
{
273273
let hash = self.map.hash(key);
274274
self.from_key_hashed_nocheck(hash.get(), key)
275275
}
276276

277277
/// Access an entry by a key and its hash.
278-
pub fn from_key_hashed_nocheck<Q: ?Sized>(self, hash: u64, key: &Q) -> RawEntryMut<'a, K, V, S>
278+
pub fn from_key_hashed_nocheck<Q>(self, hash: u64, key: &Q) -> RawEntryMut<'a, K, V, S>
279279
where
280-
Q: Equivalent<K>,
280+
Q: ?Sized + Equivalent<K>,
281281
{
282282
self.from_hash(hash, |k| Q::equivalent(key, k))
283283
}

src/map/mutable.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ pub trait MutableKeys: private::Sealed {
2323
/// Return item index, mutable reference to key and value
2424
///
2525
/// Computes in **O(1)** time (average).
26-
fn get_full_mut2<Q: ?Sized>(
27-
&mut self,
28-
key: &Q,
29-
) -> Option<(usize, &mut Self::Key, &mut Self::Value)>
26+
fn get_full_mut2<Q>(&mut self, key: &Q) -> Option<(usize, &mut Self::Key, &mut Self::Value)>
3027
where
31-
Q: Hash + Equivalent<Self::Key>;
28+
Q: ?Sized + Hash + Equivalent<Self::Key>;
3229

3330
/// Return mutable reference to key and value at an index.
3431
///
@@ -59,9 +56,9 @@ where
5956
type Key = K;
6057
type Value = V;
6158

62-
fn get_full_mut2<Q: ?Sized>(&mut self, key: &Q) -> Option<(usize, &mut K, &mut V)>
59+
fn get_full_mut2<Q>(&mut self, key: &Q) -> Option<(usize, &mut K, &mut V)>
6360
where
64-
Q: Hash + Equivalent<K>,
61+
Q: ?Sized + Hash + Equivalent<K>,
6562
{
6663
if let Some(i) = self.get_index_of(key) {
6764
let entry = &mut self.as_entries_mut()[i];

src/set.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ where
510510
/// Return `true` if an equivalent to `value` exists in the set.
511511
///
512512
/// Computes in **O(1)** time (average).
513-
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
513+
pub fn contains<Q>(&self, value: &Q) -> bool
514514
where
515-
Q: Hash + Equivalent<T>,
515+
Q: ?Sized + Hash + Equivalent<T>,
516516
{
517517
self.map.contains_key(value)
518518
}
@@ -521,27 +521,27 @@ where
521521
/// else `None`.
522522
///
523523
/// Computes in **O(1)** time (average).
524-
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
524+
pub fn get<Q>(&self, value: &Q) -> Option<&T>
525525
where
526-
Q: Hash + Equivalent<T>,
526+
Q: ?Sized + Hash + Equivalent<T>,
527527
{
528528
self.map.get_key_value(value).map(|(x, &())| x)
529529
}
530530

531531
/// Return item index and value
532-
pub fn get_full<Q: ?Sized>(&self, value: &Q) -> Option<(usize, &T)>
532+
pub fn get_full<Q>(&self, value: &Q) -> Option<(usize, &T)>
533533
where
534-
Q: Hash + Equivalent<T>,
534+
Q: ?Sized + Hash + Equivalent<T>,
535535
{
536536
self.map.get_full(value).map(|(i, x, &())| (i, x))
537537
}
538538

539539
/// Return item index, if it exists in the set
540540
///
541541
/// Computes in **O(1)** time (average).
542-
pub fn get_index_of<Q: ?Sized>(&self, value: &Q) -> Option<usize>
542+
pub fn get_index_of<Q>(&self, value: &Q) -> Option<usize>
543543
where
544-
Q: Hash + Equivalent<T>,
544+
Q: ?Sized + Hash + Equivalent<T>,
545545
{
546546
self.map.get_index_of(value)
547547
}
@@ -554,9 +554,9 @@ where
554554
/// [`.shift_remove(value)`][Self::shift_remove] instead.
555555
#[deprecated(note = "`remove` disrupts the set order -- \
556556
use `swap_remove` or `shift_remove` for explicit behavior.")]
557-
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
557+
pub fn remove<Q>(&mut self, value: &Q) -> bool
558558
where
559-
Q: Hash + Equivalent<T>,
559+
Q: ?Sized + Hash + Equivalent<T>,
560560
{
561561
self.swap_remove(value)
562562
}
@@ -570,9 +570,9 @@ where
570570
/// Return `false` if `value` was not in the set.
571571
///
572572
/// Computes in **O(1)** time (average).
573-
pub fn swap_remove<Q: ?Sized>(&mut self, value: &Q) -> bool
573+
pub fn swap_remove<Q>(&mut self, value: &Q) -> bool
574574
where
575-
Q: Hash + Equivalent<T>,
575+
Q: ?Sized + Hash + Equivalent<T>,
576576
{
577577
self.map.swap_remove(value).is_some()
578578
}
@@ -586,9 +586,9 @@ where
586586
/// Return `false` if `value` was not in the set.
587587
///
588588
/// Computes in **O(n)** time (average).
589-
pub fn shift_remove<Q: ?Sized>(&mut self, value: &Q) -> bool
589+
pub fn shift_remove<Q>(&mut self, value: &Q) -> bool
590590
where
591-
Q: Hash + Equivalent<T>,
591+
Q: ?Sized + Hash + Equivalent<T>,
592592
{
593593
self.map.shift_remove(value).is_some()
594594
}
@@ -602,9 +602,9 @@ where
602602
/// [`.shift_take(value)`][Self::shift_take] instead.
603603
#[deprecated(note = "`take` disrupts the set order -- \
604604
use `swap_take` or `shift_take` for explicit behavior.")]
605-
pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
605+
pub fn take<Q>(&mut self, value: &Q) -> Option<T>
606606
where
607-
Q: Hash + Equivalent<T>,
607+
Q: ?Sized + Hash + Equivalent<T>,
608608
{
609609
self.swap_take(value)
610610
}
@@ -619,9 +619,9 @@ where
619619
/// Return `None` if `value` was not in the set.
620620
///
621621
/// Computes in **O(1)** time (average).
622-
pub fn swap_take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
622+
pub fn swap_take<Q>(&mut self, value: &Q) -> Option<T>
623623
where
624-
Q: Hash + Equivalent<T>,
624+
Q: ?Sized + Hash + Equivalent<T>,
625625
{
626626
self.map.swap_remove_entry(value).map(|(x, ())| x)
627627
}
@@ -636,9 +636,9 @@ where
636636
/// Return `None` if `value` was not in the set.
637637
///
638638
/// Computes in **O(n)** time (average).
639-
pub fn shift_take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
639+
pub fn shift_take<Q>(&mut self, value: &Q) -> Option<T>
640640
where
641-
Q: Hash + Equivalent<T>,
641+
Q: ?Sized + Hash + Equivalent<T>,
642642
{
643643
self.map.shift_remove_entry(value).map(|(x, ())| x)
644644
}
@@ -650,9 +650,9 @@ where
650650
/// the position of what used to be the last element!**
651651
///
652652
/// Return `None` if `value` was not in the set.
653-
pub fn swap_remove_full<Q: ?Sized>(&mut self, value: &Q) -> Option<(usize, T)>
653+
pub fn swap_remove_full<Q>(&mut self, value: &Q) -> Option<(usize, T)>
654654
where
655-
Q: Hash + Equivalent<T>,
655+
Q: ?Sized + Hash + Equivalent<T>,
656656
{
657657
self.map.swap_remove_full(value).map(|(i, x, ())| (i, x))
658658
}
@@ -664,9 +664,9 @@ where
664664
/// **This perturbs the index of all of those elements!**
665665
///
666666
/// Return `None` if `value` was not in the set.
667-
pub fn shift_remove_full<Q: ?Sized>(&mut self, value: &Q) -> Option<(usize, T)>
667+
pub fn shift_remove_full<Q>(&mut self, value: &Q) -> Option<(usize, T)>
668668
where
669-
Q: Hash + Equivalent<T>,
669+
Q: ?Sized + Hash + Equivalent<T>,
670670
{
671671
self.map.shift_remove_full(value).map(|(i, x, ())| (i, x))
672672
}

0 commit comments

Comments
 (0)