Skip to content

Commit 2957e2a

Browse files
authored
Merge pull request #334 from epage/template
chore: Update from _rust template
2 parents 967edba + c416e90 commit 2957e2a

File tree

10 files changed

+20
-20
lines changed

10 files changed

+20
-20
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
- uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.x'
2729
- uses: pre-commit/[email protected]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp
4545
PRs should tell a cohesive story, with test and refactor commits that keep the
4646
fix or feature commits simple and clear.
4747

48-
Specifically, we would encouage
48+
Specifically, we would encourage
4949
- File renames be isolated into their own commit
5050
- Add tests in a commit before their feature or fix, showing the current behavior.
5151
The diff for the feature/fix commit will then show how the behavior changed,

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ string_lit_as_bytes = "warn"
8282
string_to_string = "warn"
8383
todo = "warn"
8484
trait_duplication_in_bounds = "warn"
85+
uninlined_format_args = "warn"
8586
verbose_file_reads = "warn"
8687
wildcard_imports = "warn"
8788
zero_sized_map_values = "warn"

crates/env_filter/src/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
6262
let mods = parts.next();
6363
let filter = parts.next();
6464
if parts.next().is_some() {
65-
result.add_error(format!("invalid logging spec '{}' (too many '/'s)", spec));
65+
result.add_error(format!("invalid logging spec '{spec}' (too many '/'s)"));
6666
return result;
6767
}
6868
if let Some(m) = mods {
@@ -86,12 +86,12 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
8686
if let Ok(num) = part1.parse() {
8787
(num, Some(part0))
8888
} else {
89-
result.add_error(format!("invalid logging spec '{}'", part1));
89+
result.add_error(format!("invalid logging spec '{part1}'"));
9090
continue;
9191
}
9292
}
9393
_ => {
94-
result.add_error(format!("invalid logging spec '{}'", s));
94+
result.add_error(format!("invalid logging spec '{s}'"));
9595
continue;
9696
}
9797
};
@@ -106,7 +106,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
106106
if let Some(filter) = filter {
107107
match FilterOp::new(filter) {
108108
Ok(filter_op) => result.set_filter(filter_op),
109-
Err(err) => result.add_error(format!("invalid regex filter - {}", err)),
109+
Err(err) => result.add_error(format!("invalid regex filter - {err}")),
110110
}
111111
}
112112

src/fmt/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ impl<'a> DefaultFormat<'a> {
357357
self.written_header_value = true;
358358

359359
let open_brace = self.subtle_style("[");
360-
write!(self.buf, "{}{}", open_brace, value)
360+
write!(self.buf, "{open_brace}{value}")
361361
} else {
362-
write!(self.buf, " {}", value)
362+
write!(self.buf, " {value}")
363363
}
364364
}
365365

@@ -383,7 +383,7 @@ impl<'a> DefaultFormat<'a> {
383383
}
384384
};
385385

386-
self.write_header_value(format_args!("{:<5}", level))
386+
self.write_header_value(format_args!("{level:<5}"))
387387
}
388388

389389
fn write_timestamp(&mut self) -> io::Result<()> {
@@ -435,7 +435,7 @@ impl<'a> DefaultFormat<'a> {
435435
fn finish_header(&mut self) -> io::Result<()> {
436436
if self.written_header_value {
437437
let close_brace = self.subtle_style("]");
438-
write!(self.buf, "{} ", close_brace)
438+
write!(self.buf, "{close_brace} ")
439439
} else {
440440
Ok(())
441441
}

src/fmt/writer/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl BufferWriter {
7171
#[cfg(feature = "color")]
7272
let buf = &buf;
7373
let buf = String::from_utf8_lossy(buf);
74-
print!("{}", buf);
74+
print!("{buf}");
7575
}
7676
WritableTarget::WriteStderr => {
7777
let stream = io::stderr();
@@ -87,7 +87,7 @@ impl BufferWriter {
8787
#[cfg(feature = "color")]
8888
let buf = &buf;
8989
let buf = String::from_utf8_lossy(buf);
90-
eprint!("{}", buf);
90+
eprint!("{buf}");
9191
}
9292
WritableTarget::Pipe(pipe) => {
9393
#[cfg(feature = "color")]

tests/init-twice-retains-filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
.env("YOU_ARE_TESTING_NOW", "1")
2828
.env("RUST_LOG", "debug")
2929
.output()
30-
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
30+
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
3131
if out.status.success() {
3232
return;
3333
}

tests/log-in-log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
.env("YOU_ARE_TESTING_NOW", "1")
2929
.env("RUST_LOG", "debug")
3030
.output()
31-
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
31+
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
3232
if out.status.success() {
3333
return;
3434
}

tests/log_tls_dtors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn main() {
5656
.env("YOU_ARE_TESTING_NOW", "1")
5757
.env("RUST_LOG", "debug")
5858
.output()
59-
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
59+
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
6060
if !out.status.success() {
6161
println!("test failed: {}", out.status);
6262
println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap());

tests/regexp_filter.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,21 @@ fn run_child(rust_log: String) -> bool {
2626
.env("LOG_REGEXP_TEST", "1")
2727
.env("RUST_LOG", rust_log)
2828
.output()
29-
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
29+
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
3030
str::from_utf8(out.stderr.as_ref())
3131
.unwrap()
3232
.contains("XYZ Message")
3333
}
3434

3535
fn assert_message_printed(rust_log: &str) {
3636
if !run_child(rust_log.to_owned()) {
37-
panic!("RUST_LOG={} should allow the test log message", rust_log)
37+
panic!("RUST_LOG={rust_log} should allow the test log message")
3838
}
3939
}
4040

4141
fn assert_message_not_printed(rust_log: &str) {
4242
if run_child(rust_log.to_owned()) {
43-
panic!(
44-
"RUST_LOG={} should not allow the test log message",
45-
rust_log
46-
)
43+
panic!("RUST_LOG={rust_log} should not allow the test log message")
4744
}
4845
}
4946

0 commit comments

Comments
 (0)