Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some Clippy warnings #252

Merged
merged 1 commit into from Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion phf/src/map.rs
Expand Up @@ -115,7 +115,7 @@ impl<K, V> Map<K, V> {
return None;
} //Prevent panic on empty map
let hashes = phf_shared::hash(key, &self.key);
let index = phf_shared::get_index(&hashes, &*self.disps, self.entries.len());
let index = phf_shared::get_index(&hashes, self.disps, self.entries.len());
let entry = &self.entries[index as usize];
let b: &T = entry.0.borrow();
if b == key {
Expand Down
2 changes: 1 addition & 1 deletion phf/src/ordered_map.rs
Expand Up @@ -126,7 +126,7 @@ impl<K, V> OrderedMap<K, V> {
return None;
} //Prevent panic on empty map
let hashes = phf_shared::hash(key, &self.key);
let idx_index = phf_shared::get_index(&hashes, &*self.disps, self.idxs.len());
let idx_index = phf_shared::get_index(&hashes, self.disps, self.idxs.len());
let idx = self.idxs[idx_index as usize];
let entry = &self.entries[idx];

Expand Down
1 change: 1 addition & 0 deletions phf_codegen/src/lib.rs
Expand Up @@ -129,6 +129,7 @@
//! ```

#![doc(html_root_url = "https://docs.rs/phf_codegen/0.10")]
#![allow(clippy::new_without_default)]

use phf_shared::{FmtConst, PhfHash};
use std::collections::HashSet;
Expand Down
8 changes: 4 additions & 4 deletions phf_codegen/test/src/lib.rs
Expand Up @@ -70,10 +70,10 @@ mod test {

#[test]
fn uncased_map() {
assert_eq!("a", UNCASED_MAP[&UncasedStr::new("AbC")]);
assert_eq!("a", UNCASED_MAP[&UncasedStr::new("abc")]);
assert_eq!("b", UNCASED_MAP[&UncasedStr::new("DEf")]);
assert!(!UNCASED_MAP.contains_key(&UncasedStr::new("XyZ")));
assert_eq!("a", UNCASED_MAP[UncasedStr::new("AbC")]);
assert_eq!("a", UNCASED_MAP[UncasedStr::new("abc")]);
assert_eq!("b", UNCASED_MAP[UncasedStr::new("DEf")]);
assert!(!UNCASED_MAP.contains_key(UncasedStr::new("XyZ")));
}

#[test]
Expand Down
58 changes: 29 additions & 29 deletions phf_macros_tests/tests/test.rs
Expand Up @@ -23,9 +23,9 @@ mod map {
"foo" => 10,
"bar" => 11,
);
assert!(Some(&10) == MAP.get(&("foo")));
assert!(Some(&11) == MAP.get(&("bar")));
assert_eq!(None, MAP.get(&("asdf")));
assert!(Some(&10) == MAP.get("foo"));
assert!(Some(&11) == MAP.get("bar"));
assert_eq!(None, MAP.get("asdf"));
assert_eq!(2, MAP.len());
}

Expand All @@ -50,7 +50,7 @@ mod map {
"foo" => 10,
"bar" => 11,
);
let hash = MAP.keys().map(|&e| e).collect::<HashSet<_>>();
let hash = MAP.keys().copied().collect::<HashSet<_>>();
assert!(hash.contains(&("foo")));
assert!(hash.contains(&("bar")));
assert_eq!(2, hash.len());
Expand All @@ -62,7 +62,7 @@ mod map {
"foo" => 10,
"bar" => 11,
);
let hash = MAP.values().map(|&e| e).collect::<HashSet<isize>>();
let hash = MAP.values().copied().collect::<HashSet<isize>>();
assert!(hash.contains(&10));
assert!(hash.contains(&11));
assert_eq!(2, hash.len());
Expand Down Expand Up @@ -98,7 +98,7 @@ mod map {
"y" => 24,
"z" => 25,
);
assert!(MAP.get(&("a")) == Some(&0));
assert!(MAP.get("a") == Some(&0));
}

#[test]
Expand All @@ -123,7 +123,7 @@ mod map {
static MAP: phf::Map<&'static str, isize> = phf_map!(
"a" => 0,
);
MAP["b"];
let _ = MAP["b"];
}

macro_rules! test_key_type(
Expand All @@ -142,7 +142,7 @@ mod map {
static MAP: phf::Map<&'static str, [u8; 3]> = phf_map!(
"a" => [0u8, 1, 2],
);
assert_eq!(Some(&[0u8, 1, 2]), MAP.get(&("a")));
assert_eq!(Some(&[0u8, 1, 2]), MAP.get("a"));
}

#[test]
Expand Down Expand Up @@ -273,9 +273,9 @@ mod set {
"hello",
"world",
};
assert!(SET.contains(&"hello"));
assert!(SET.contains(&"world"));
assert!(!SET.contains(&"foo"));
assert!(SET.contains("hello"));
assert!(SET.contains("world"));
assert!(!SET.contains("foo"));
assert_eq!(2, SET.len());
}

Expand All @@ -285,7 +285,7 @@ mod set {
"hello",
"world",
};
let set = SET.iter().map(|e| *e).collect::<HashSet<_>>();
let set = SET.iter().copied().collect::<HashSet<_>>();
assert!(set.contains(&"hello"));
assert!(set.contains(&"world"));
assert_eq!(2, set.len());
Expand Down Expand Up @@ -331,9 +331,9 @@ mod ordered_map {
"foo" => 10,
"bar" => 11,
);
assert!(Some(&10) == MAP.get(&"foo"));
assert!(Some(&11) == MAP.get(&"bar"));
assert_eq!(None, MAP.get(&"asdf"));
assert!(Some(&10) == MAP.get("foo"));
assert!(Some(&11) == MAP.get("bar"));
assert_eq!(None, MAP.get("asdf"));
assert_eq!(2, MAP.len());
}

Expand All @@ -344,9 +344,9 @@ mod ordered_map {
"bar" => 5,
"baz" => 5,
);
assert_eq!(Some(0), MAP.get_index(&"foo"));
assert_eq!(Some(2), MAP.get_index(&"baz"));
assert_eq!(None, MAP.get_index(&"xyz"));
assert_eq!(Some(0), MAP.get_index("foo"));
assert_eq!(Some(2), MAP.get_index("baz"));
assert_eq!(None, MAP.get_index("xyz"));

assert_eq!(Some(0), MAP.get_index(&*"foo".to_string()));
assert_eq!(Some(2), MAP.get_index(&*"baz".to_string()));
Expand Down Expand Up @@ -382,7 +382,7 @@ mod ordered_map {
"bar" => 11,
"baz" => 12,
);
let vec = MAP.keys().map(|&e| e).collect::<Vec<_>>();
let vec = MAP.keys().copied().collect::<Vec<_>>();
assert_eq!(vec, vec!("foo", "bar", "baz"));
}

Expand All @@ -393,7 +393,7 @@ mod ordered_map {
"bar" => 11,
"baz" => 12,
);
let vec = MAP.values().map(|&v| v).collect::<Vec<_>>();
let vec = MAP.values().copied().collect::<Vec<_>>();
assert_eq!(vec, vec!(10, 11, 12));
}

Expand All @@ -411,7 +411,7 @@ mod ordered_map {
static MAP: phf::OrderedMap<&'static str, isize> = phf_ordered_map!(
"a" => 0,
);
MAP["b"];
let _ = MAP["b"];
}

#[test]
Expand Down Expand Up @@ -455,10 +455,10 @@ mod ordered_set {
"there",
"world",
};
assert!(SET.contains(&"hello"));
assert!(SET.contains(&"there"));
assert!(SET.contains(&"world"));
assert!(!SET.contains(&"foo"));
assert!(SET.contains("hello"));
assert!(SET.contains("there"));
assert!(SET.contains("world"));
assert!(!SET.contains("foo"));
assert_eq!(3, SET.len());
}

Expand All @@ -469,9 +469,9 @@ mod ordered_set {
"bar",
"baz",
};
assert_eq!(Some(0), SET.get_index(&"foo"));
assert_eq!(Some(2), SET.get_index(&"baz"));
assert_eq!(None, SET.get_index(&"xyz"));
assert_eq!(Some(0), SET.get_index("foo"));
assert_eq!(Some(2), SET.get_index("baz"));
assert_eq!(None, SET.get_index("xyz"));

assert_eq!(Some(0), SET.get_index(&*"foo".to_string()));
assert_eq!(Some(2), SET.get_index(&*"baz".to_string()));
Expand All @@ -493,7 +493,7 @@ mod ordered_set {
"there",
"world",
};
let vec = SET.iter().map(|&e| e).collect::<Vec<_>>();
let vec = SET.iter().copied().collect::<Vec<_>>();
assert_eq!(vec, vec!("hello", "there", "world"));
}

Expand Down