diff --git a/examples/names.rs b/examples/names.rs index 0a8ccfc..4e0fb2a 100644 --- a/examples/names.rs +++ b/examples/names.rs @@ -76,7 +76,7 @@ fn main() -> Result<(), Box> { _ => return Err("expected player stats to be an array".into()), }; - let header_names = names_in_header(&stats); + let header_names = names_in_header(stats); for name in header_names { println!("{}", name); } diff --git a/examples/ping.rs b/examples/ping.rs index 6bc16dc..4d17865 100644 --- a/examples/ping.rs +++ b/examples/ping.rs @@ -99,7 +99,7 @@ fn main() -> Result<(), Box> { // Fill in the name of the latest entry with the same // actor id that either has the same name or no name. let entry = actor_pings.iter().rev().rposition(|x| { - x.actor_id == act_id && x.name.as_ref().map_or(true, |n| n == &name) + x.actor_id == act_id && x.name.as_ref().is_none_or(|n| n == &name) }); if let Some(position) = entry { actor_pings[position].name.replace(name); @@ -111,7 +111,7 @@ fn main() -> Result<(), Box> { }); } } else { - return Err("expected player name to be a string")?; + Err("expected player name to be a string")?; } } else if attr.object_id == ping_id { if let Attribute::Byte(ping) = attr.attribute { @@ -130,7 +130,7 @@ fn main() -> Result<(), Box> { }); } } else { - return Err("expected ping to be a byte")?; + Err("expected ping to be a byte")?; } } } @@ -149,7 +149,7 @@ fn main() -> Result<(), Box> { .and_modify(|e| { e.extend_from_slice(&player.pings); }) - .or_insert_with(Vec::new); + .or_default(); } for (player, pings) in &pings { diff --git a/examples/property_counter.rs b/examples/property_counter.rs index 9f9aab3..2c285d2 100644 --- a/examples/property_counter.rs +++ b/examples/property_counter.rs @@ -13,7 +13,7 @@ fn count_properties( prefix: &str, ) { for (key, prop) in props.iter() { - let new_prefix = if prefix == "" { + let new_prefix = if prefix.is_empty() { Cow::Borrowed(key) } else { Cow::Owned(format!("{}:{}", prefix, key)) diff --git a/tests/samples.rs b/tests/samples.rs index c1cc323..25449f1 100644 --- a/tests/samples.rs +++ b/tests/samples.rs @@ -224,14 +224,14 @@ fn test_preserve_endian() { boxcars::Attribute::LoadoutsOnline(x) => Some(x.blue.iter().flat_map(|pr| pr.iter())), _ => None, }) - .flat_map(|x| x) + .flatten() .filter_map(|x| match x.value { boxcars::attributes::ProductValue::NewPaint(p) => Some(p), _ => None, }) .collect::>(); - assert_eq!(*new_paints.get(0).unwrap(), 11); + assert_eq!(*new_paints.first().unwrap(), 11); } #[test]