Resolve clippy warnings

This commit is contained in:
timvisee
2023-02-10 11:11:05 +01:00
parent eb2cf1219e
commit be74e053f4
5 changed files with 10 additions and 14 deletions

View File

@@ -122,7 +122,7 @@ fn rewrite_contents(contents: String, mut changes: HashMap<&str, String>) -> Opt
// Take any new value, and update it // Take any new value, and update it
if let Some((_, new)) = changes.remove_entry(key.trim().to_lowercase().as_str()) { if let Some((_, new)) = changes.remove_entry(key.trim().to_lowercase().as_str()) {
if value != new { if value != new {
line = format!("{}={}", key, new); line = format!("{key}={new}");
changed = true; changed = true;
} }
} }
@@ -134,7 +134,7 @@ fn rewrite_contents(contents: String, mut changes: HashMap<&str, String>) -> Opt
// Append any missed changes // Append any missed changes
for (key, value) in changes { for (key, value) in changes {
new_contents += &format!("{}{}={}", EOL, key, value); new_contents += &format!("{EOL}{key}={value}");
changed = true; changed = true;
} }

View File

@@ -11,7 +11,7 @@ fn player_uuid(username: &str) -> Uuid {
/// Get UUID for given offline player username. /// Get UUID for given offline player username.
pub fn offline_player_uuid(username: &str) -> Uuid { pub fn offline_player_uuid(username: &str) -> Uuid {
player_uuid(&format!("{}{}", OFFLINE_PLAYER_NAMESPACE, username)) player_uuid(&format!("{OFFLINE_PLAYER_NAMESPACE}{username}"))
} }
/// Java's `UUID.nameUUIDFromBytes` /// Java's `UUID.nameUUIDFromBytes`

View File

@@ -152,12 +152,8 @@ pub async fn serve(
info!(target: "lazymc", "Login from banned IP {}, disconnecting", client.peer.ip()); info!(target: "lazymc", "Login from banned IP {}, disconnecting", client.peer.ip());
DEFAULT_BAN_REASON.to_string() DEFAULT_BAN_REASON.to_string()
}; };
action::kick( action::kick(&client, &format!("{BAN_MESSAGE_PREFIX}{msg}"), &mut writer)
&client, .await?;
&format!("{}{}", BAN_MESSAGE_PREFIX, msg),
&mut writer,
)
.await?;
break; break;
} }
} }

View File

@@ -10,7 +10,7 @@ use crate::util::error::{quit_error, ErrorHints};
/// excluding the `:` suffix. /// excluding the `:` suffix.
pub fn prompt(msg: &str) -> String { pub fn prompt(msg: &str) -> String {
// Show the prompt // Show the prompt
eprint!("{}: ", msg); eprint!("{msg}: ");
let _ = stderr().flush(); let _ = stderr().flush();
// Get the input // Get the input
@@ -49,7 +49,7 @@ pub fn prompt_yes(msg: &str, def: Option<bool>) -> bool {
); );
// Get the user input // Get the user input
let answer = prompt(&format!("{} {}", msg, options)); let answer = prompt(&format!("{msg} {options}"));
// Assume the default if the answer is empty // Assume the default if the answer is empty
if answer.is_empty() { if answer.is_empty() {

View File

@@ -16,7 +16,7 @@ pub fn print_error(err: anyhow::Error) {
// Report each printable error, count them // Report each printable error, count them
let count = err let count = err
.chain() .chain()
.map(|err| format!("{}", err)) .map(|err| err.to_string())
.filter(|err| !err.is_empty()) .filter(|err| !err.is_empty())
.enumerate() .enumerate()
.map(|(i, err)| { .map(|(i, err)| {
@@ -126,7 +126,7 @@ impl ErrorHints {
if self.config_generate { if self.config_generate {
eprintln!( eprintln!(
"Use '{}' to generate a new config file", "Use '{}' to generate a new config file",
highlight(&format!("{} config generate", bin)) highlight(&format!("{bin} config generate"))
); );
} }
if self.config { if self.config {
@@ -138,7 +138,7 @@ impl ErrorHints {
if self.config_test { if self.config_test {
eprintln!( eprintln!(
"Use '{}' to test a config file", "Use '{}' to test a config file",
highlight(&format!("{} config test -c FILE", bin)) highlight(&format!("{bin} config test -c FILE"))
); );
} }
if self.verbose { if self.verbose {