clippy: Use write! rather than push_str, format
This does involve unwrap, but of course that can't fail unless the formats fail, which would already panic (that's implied by format!).
This commit is contained in:
parent
4a06ce01e1
commit
0717595781
|
@ -122,6 +122,8 @@ pub mod process;
|
|||
pub mod socks;
|
||||
pub mod watch_cfg;
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
pub use cfg::{
|
||||
ApplicationConfig, ApplicationConfigBuilder, ArtiConfig, ArtiConfigBuilder, ProxyConfig,
|
||||
ProxyConfigBuilder, SystemConfig, SystemConfigBuilder,
|
||||
|
@ -267,7 +269,7 @@ pub fn main_main() -> Result<()> {
|
|||
// If we couldn't resolve the default config file, then too bad. If something
|
||||
// actually tries to use it, it will produce an error, but don't fail here
|
||||
// just for that reason.
|
||||
config_file_help.push_str(&format!(" Defaults to {:?}", default));
|
||||
write!(config_file_help, " Defaults to {:?}", default).unwrap();
|
||||
}
|
||||
|
||||
// We create the runtime now so that we can use its `Debug` impl to describe it for
|
||||
|
|
|
@ -8,6 +8,7 @@ use crate::chancell::msg::{DestroyReason, TAP_C_HANDSHAKE_LEN, TAP_S_HANDSHAKE_L
|
|||
use crate::chancell::CELL_DATA_LEN;
|
||||
use caret::caret_int;
|
||||
use educe::Educe;
|
||||
use std::fmt::Write;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use tor_bytes::{Error, Result};
|
||||
use tor_bytes::{Readable, Reader, Writeable, Writer};
|
||||
|
@ -921,9 +922,9 @@ impl Resolve {
|
|||
for o in v6.octets().iter().rev() {
|
||||
let high_nybble = o >> 4;
|
||||
let low_nybble = o & 15;
|
||||
s.push_str(&format!("{:x}.{:x}.", low_nybble, high_nybble));
|
||||
write!(s, "{:x}.{:x}.", low_nybble, high_nybble).unwrap();
|
||||
}
|
||||
s.push_str("ip6.arpa");
|
||||
write!(s, "ip6.arpa").unwrap();
|
||||
s
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
//! Helper functions for the directory client code
|
||||
|
||||
use std::fmt::Write;
|
||||
|
||||
/// Encode an HTTP request in a quick and dirty HTTP 1.0 format.
|
||||
pub(crate) fn encode_request(req: &http::Request<()>) -> String {
|
||||
let mut s = format!("{} {} HTTP/1.0\r\n", req.method(), req.uri());
|
||||
|
||||
for (key, val) in req.headers().iter() {
|
||||
s.push_str(&format!(
|
||||
write!(
|
||||
s,
|
||||
"{}: {}\r\n",
|
||||
key,
|
||||
val.to_str()
|
||||
.expect("Added an HTTP header that wasn't UTF-8!")
|
||||
));
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
s.push_str("\r\n");
|
||||
s
|
||||
|
|
Loading…
Reference in New Issue