From 041b0c1e3dbffe8624d48c9486de30c0c38c8f4f Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 26 Apr 2024 15:33:14 +0700 Subject: [PATCH] xilem_web: Fix clippy::multiple_bound_locations lints. Define generic bounds once rather than partly in the bound predicate and partly in the `where` clause. --- crates/xilem_web/src/vecmap.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/xilem_web/src/vecmap.rs b/crates/xilem_web/src/vecmap.rs index 10d1ddfe40..7b7de83847 100644 --- a/crates/xilem_web/src/vecmap.rs +++ b/crates/xilem_web/src/vecmap.rs @@ -34,10 +34,10 @@ impl VecMap { /// assert_eq!(map.get(&1), Some(&"a")); /// assert_eq!(map.get(&2), None); /// ``` - pub fn get(&self, key: &Q) -> Option<&V> + pub fn get(&self, key: &Q) -> Option<&V> where K: Borrow + PartialEq, - Q: PartialEq, + Q: PartialEq + ?Sized, { self.0 .iter() @@ -60,10 +60,10 @@ impl VecMap { /// assert!(map.contains_key(&1)); /// assert!(!map.contains_key(&2)); /// ``` - pub fn contains_key(&self, key: &Q) -> bool + pub fn contains_key(&self, key: &Q) -> bool where K: Borrow + Ord, - Q: Ord, + Q: Ord + ?Sized, { self.get(key).is_some() } @@ -87,10 +87,10 @@ impl VecMap { /// assert_eq!(map[&1], "b"); /// ``` // See `get` for implementation notes, this is basically a copy-paste with mut's added - pub fn get_mut(&mut self, key: &Q) -> Option<&mut V> + pub fn get_mut(&mut self, key: &Q) -> Option<&mut V> where K: Borrow + Ord, - Q: Ord, + Q: Ord + ?Sized, { self.0 .iter_mut() @@ -197,10 +197,10 @@ impl VecMap { /// assert_eq!(map.remove(&1), Some("a")); /// assert_eq!(map.remove(&1), None); /// ``` - pub fn remove(&mut self, key: &Q) -> Option + pub fn remove(&mut self, key: &Q) -> Option where K: Borrow + Ord, - Q: Ord, + Q: Ord + ?Sized, { // TODO not sure whether just a simple find is better here? Probably needs more benching match self.0.binary_search_by_key(&key, |(k, _)| k.borrow()) { @@ -248,10 +248,10 @@ impl VecMap { } } -impl Index<&Q> for VecMap +impl Index<&Q> for VecMap where K: Borrow + Ord, - Q: Ord, + Q: Ord + ?Sized, { type Output = V;