Style and Clippy fixes.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-10-14 16:53:30 +02:00
parent 9efe1b4e22
commit 691bf7c12e
56 changed files with 354 additions and 249 deletions

View File

@@ -116,11 +116,12 @@ impl Display for StringKey {
}
}
impl Into<StringKey> for &CStr {
fn into(self) -> StringKey {
StringKey::new(self.to_str().unwrap())
impl From<&CStr> for StringKey {
fn from(s: &CStr) -> Self {
StringKey::new(s.to_str().unwrap())
}
}
/// Converts a character to lowercased in a const safe way.
const fn to_lower(c: u8) -> u8 {
if c >= b'A' && c <= b'Z' {
@@ -170,7 +171,7 @@ mod tests {
#[test]
fn create_empty_stringkey() {
let sk = StringKey::new("".into());
let sk = StringKey::new("");
assert_eq!(sk.str(), "");
assert_eq!(sk.hash(), 0);
assert_eq!(sk.hash(), StringKey::get_hash(""));
@@ -178,7 +179,7 @@ mod tests {
#[test]
fn create_stringkey_foo() {
let sk = StringKey::new("foo".into());
let sk = StringKey::new("foo");
assert_eq!(sk.str(), "foo");
assert_eq!(sk.hash(), 2356372769);
assert_eq!(sk.hash(), StringKey::get_hash("foo"));
@@ -187,7 +188,7 @@ mod tests {
#[test]
fn create_stringkey_bar() {
let sk = StringKey::new("bar".into());
let sk = StringKey::new("bar");
assert_eq!(sk.str(), "bar");
assert_eq!(sk.hash(), 1996459178);
assert_eq!(sk.hash(), StringKey::get_hash("bar"));