diff --git a/Cargo.toml b/Cargo.toml index c93a5705..4d10883b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ empty_structs_with_brackets = "warn" error_impl_error = "warn" filetype_is_file = "warn" float_cmp_const = "warn" +format_push_string = "warn" get_unwrap = "warn" lossy_float_literal = "warn" mem_forget = "warn" diff --git a/src/config.rs b/src/config.rs index f10819b5..539a26f9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,7 @@ use std::{ collections::BTreeMap, fmt, + fmt::Write, net::{IpAddr, Ipv4Addr}, }; @@ -191,7 +192,8 @@ impl fmt::Display for Config { let mut msg: String = "Active config values:\n\n".to_owned(); for line in lines.into_iter().enumerate() { - msg += &format!("{}: {}\n", line.1 .0, line.1 .1); + writeln!(msg, "{}: {}", line.1 .0, line.1 .1) + .expect("write to in-memory buffer should succeed"); } write!(f, "{msg}") diff --git a/src/service/admin.rs b/src/service/admin.rs index f61938a1..f3cd40fc 100644 --- a/src/service/admin.rs +++ b/src/service/admin.rs @@ -1,6 +1,7 @@ use std::{ collections::BTreeMap, convert::{TryFrom, TryInto}, + fmt::Write, sync::Arc, time::Instant, }; @@ -413,13 +414,13 @@ impl Service { for (r, (e, i)) in map.iter() { let elapsed = i.elapsed(); - msg += &format!( - "{} {}: {}m{}s\n", - r, - e, + writeln!( + msg, + "{r} {e}: {}m{}s", elapsed.as_secs() / 60, elapsed.as_secs() % 60 - ); + ) + .expect("write to in-memory buffer should succeed"); } RoomMessageEventContent::text_plain(&msg) } @@ -718,8 +719,10 @@ impl Service { markdown_message.push_str("The following user ids are not valid:\n```\n"); html_message.push_str("The following user ids are not valid:\n
\n");
for invalid_user in invalid_users {
- markdown_message.push_str(&format!("{invalid_user}\n"));
- html_message.push_str(&format!("{invalid_user}\n"));
+ writeln!(markdown_message, "{invalid_user}")
+ .expect("write to in-memory buffer should succeed");
+ writeln!(html_message, "{invalid_user}")
+ .expect("write to in-memory buffer should succeed");
}
markdown_message.push_str("```\n\n");
html_message.push_str("\n\n");
@@ -730,8 +733,10 @@ impl Service {
html_message
.push_str("The following users are not from this server:\n\n");
for remote_id in remote_ids {
- markdown_message.push_str(&format!("{remote_id}\n"));
- html_message.push_str(&format!("{remote_id}\n"));
+ writeln!(markdown_message, "{remote_id}")
+ .expect("write to in-memory buffer should succeed");
+ writeln!(html_message, "{remote_id}")
+ .expect("write to in-memory buffer should succeed");
}
markdown_message.push_str("```\n\n");
html_message.push_str("\n\n");
@@ -740,8 +745,10 @@ impl Service {
markdown_message.push_str("The following users do not exist:\n```\n");
html_message.push_str("The following users do not exist:\n\n");
for non_existant_id in non_existant_ids {
- markdown_message.push_str(&format!("{non_existant_id}\n"));
- html_message.push_str(&format!("{non_existant_id}\n"));
+ writeln!(markdown_message, "{non_existant_id}")
+ .expect("write to in-memory buffer should succeed");
+ writeln!(html_message, "{non_existant_id}")
+ .expect("write to in-memory buffer should succeed");
}
markdown_message.push_str("```\n\n");
html_message.push_str("\n\n");