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

Apply automatic clippy lints #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
_ => 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);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
// 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);
Expand All @@ -111,7 +111,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
});
}
} 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 {
Expand All @@ -130,7 +130,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
});
}
} else {
return Err("expected ping to be a byte")?;
Err("expected ping to be a byte")?;
}
}
}
Expand All @@ -149,7 +149,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.and_modify(|e| {
e.extend_from_slice(&player.pings);
})
.or_insert_with(Vec::new);
.or_default();
}

for (player, pings) in &pings {
Expand Down
2 changes: 1 addition & 1 deletion examples/property_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions tests/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();

assert_eq!(*new_paints.get(0).unwrap(), 11);
assert_eq!(*new_paints.first().unwrap(), 11);
}

#[test]
Expand Down