Skip to content

Commit

Permalink
style: Inline fmt args
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 27, 2024
1 parent 5fd6d53 commit c416e90
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 19 deletions.
8 changes: 4 additions & 4 deletions crates/env_filter/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
let mods = parts.next();
let filter = parts.next();
if parts.next().is_some() {
result.add_error(format!("invalid logging spec '{}' (too many '/'s)", spec));
result.add_error(format!("invalid logging spec '{spec}' (too many '/'s)"));
return result;
}
if let Some(m) = mods {
Expand All @@ -86,12 +86,12 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
if let Ok(num) = part1.parse() {
(num, Some(part0))
} else {
result.add_error(format!("invalid logging spec '{}'", part1));
result.add_error(format!("invalid logging spec '{part1}'"));
continue;
}
}
_ => {
result.add_error(format!("invalid logging spec '{}'", s));
result.add_error(format!("invalid logging spec '{s}'"));
continue;
}
};
Expand All @@ -106,7 +106,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
if let Some(filter) = filter {
match FilterOp::new(filter) {
Ok(filter_op) => result.set_filter(filter_op),
Err(err) => result.add_error(format!("invalid regex filter - {}", err)),
Err(err) => result.add_error(format!("invalid regex filter - {err}")),
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ impl<'a> DefaultFormat<'a> {
self.written_header_value = true;

let open_brace = self.subtle_style("[");
write!(self.buf, "{}{}", open_brace, value)
write!(self.buf, "{open_brace}{value}")
} else {
write!(self.buf, " {}", value)
write!(self.buf, " {value}")
}
}

Expand All @@ -383,7 +383,7 @@ impl<'a> DefaultFormat<'a> {
}
};

self.write_header_value(format_args!("{:<5}", level))
self.write_header_value(format_args!("{level:<5}"))
}

fn write_timestamp(&mut self) -> io::Result<()> {
Expand Down Expand Up @@ -435,7 +435,7 @@ impl<'a> DefaultFormat<'a> {
fn finish_header(&mut self) -> io::Result<()> {
if self.written_header_value {
let close_brace = self.subtle_style("]");
write!(self.buf, "{} ", close_brace)
write!(self.buf, "{close_brace} ")
} else {
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/fmt/writer/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl BufferWriter {
#[cfg(feature = "color")]
let buf = &buf;
let buf = String::from_utf8_lossy(buf);
print!("{}", buf);
print!("{buf}");
}
WritableTarget::WriteStderr => {
let stream = io::stderr();
Expand All @@ -87,7 +87,7 @@ impl BufferWriter {
#[cfg(feature = "color")]
let buf = &buf;
let buf = String::from_utf8_lossy(buf);
eprint!("{}", buf);
eprint!("{buf}");
}
WritableTarget::Pipe(pipe) => {
#[cfg(feature = "color")]
Expand Down
2 changes: 1 addition & 1 deletion tests/init-twice-retains-filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
if out.status.success() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/log-in-log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
if out.status.success() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/log_tls_dtors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
if !out.status.success() {
println!("test failed: {}", out.status);
println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap());
Expand Down
9 changes: 3 additions & 6 deletions tests/regexp_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,21 @@ fn run_child(rust_log: String) -> bool {
.env("LOG_REGEXP_TEST", "1")
.env("RUST_LOG", rust_log)
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
str::from_utf8(out.stderr.as_ref())
.unwrap()
.contains("XYZ Message")
}

fn assert_message_printed(rust_log: &str) {
if !run_child(rust_log.to_owned()) {
panic!("RUST_LOG={} should allow the test log message", rust_log)
panic!("RUST_LOG={rust_log} should allow the test log message")
}
}

fn assert_message_not_printed(rust_log: &str) {
if run_child(rust_log.to_owned()) {
panic!(
"RUST_LOG={} should not allow the test log message",
rust_log
)
panic!("RUST_LOG={rust_log} should not allow the test log message")
}
}

Expand Down

0 comments on commit c416e90

Please sign in to comment.