Skip to content

Commit c51e394

Browse files
authored
Merge pull request #366 from epage/template
chore: Update from _rust template
2 parents 3bb0868 + 3f8575f commit c51e394

File tree

13 files changed

+37
-37
lines changed

13 files changed

+37
-37
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
@@ -80,6 +80,7 @@ string_lit_as_bytes = "warn"
8080
string_to_string = "warn"
8181
todo = "warn"
8282
trait_duplication_in_bounds = "warn"
83+
uninlined_format_args = "warn"
8384
verbose_file_reads = "warn"
8485
wildcard_imports = "warn"
8586
zero_sized_map_values = "warn"

crates/snapbox/src/assert/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl std::fmt::Display for Error {
3838
if let Some(backtrace) = self.backtrace.as_ref() {
3939
writeln!(f)?;
4040
writeln!(f, "Backtrace:")?;
41-
writeln!(f, "{}", backtrace)?;
41+
writeln!(f, "{backtrace}")?;
4242
}
4343
Ok(())
4444
}

crates/snapbox/src/assert/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Assert {
168168
crate::report::Styled::new(String::new(), Default::default())
169169
} else if let Some(action_var) = self.action_var.as_deref() {
170170
self.palette
171-
.hint(format!("Update with {}=overwrite", action_var))
171+
.hint(format!("Update with {action_var}=overwrite"))
172172
} else {
173173
crate::report::Styled::new(String::new(), Default::default())
174174
};
@@ -338,7 +338,7 @@ impl Assert {
338338
}
339339
if ok {
340340
use std::io::Write;
341-
let _ = write!(stderr(), "{}", buffer);
341+
let _ = write!(stderr(), "{buffer}");
342342
match self.action {
343343
Action::Skip => unreachable!("Bailed out earlier"),
344344
Action::Ignore => {
@@ -365,7 +365,7 @@ impl Assert {
365365
&mut buffer,
366366
"{}",
367367
self.palette
368-
.hint(format_args!("Update with {}=overwrite", action_var))
368+
.hint(format_args!("Update with {action_var}=overwrite"))
369369
)
370370
.unwrap();
371371
}

crates/snapbox/src/bin/snap-fixture.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ use std::process;
88

99
fn run() -> Result<(), Box<dyn Error>> {
1010
if let Ok(text) = env::var("stdout") {
11-
println!("{}", text);
11+
println!("{text}");
1212
}
1313
if let Ok(text) = env::var("stderr") {
14-
eprintln!("{}", text);
14+
eprintln!("{text}");
1515
}
1616

1717
if env::var("echo_large").as_deref() == Ok("1") {
1818
for i in 0..(128 * 1024) {
19-
println!("{}", i);
19+
println!("{i}");
2020
}
2121
}
2222

@@ -33,7 +33,7 @@ fn run() -> Result<(), Box<dyn Error>> {
3333

3434
if let Ok(path) = env::var("cat") {
3535
let text = std::fs::read_to_string(path).unwrap();
36-
eprintln!("{}", text);
36+
eprintln!("{text}");
3737
}
3838

3939
if let Some(timeout) = env::var("sleep").ok().and_then(|s| s.parse().ok()) {
@@ -53,7 +53,7 @@ fn main() {
5353
let code = match run() {
5454
Ok(_) => 0,
5555
Err(ref e) => {
56-
write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail");
56+
write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail");
5757
1
5858
}
5959
};

crates/snapbox/src/cmd.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl OutputAssert {
496496

497497
use std::fmt::Write;
498498
let mut buf = String::new();
499-
writeln!(&mut buf, "{}", desc).unwrap();
499+
writeln!(&mut buf, "{desc}").unwrap();
500500
self.write_stdout(&mut buf).unwrap();
501501
self.write_stderr(&mut buf).unwrap();
502502
panic!("{}", buf);
@@ -526,7 +526,7 @@ impl OutputAssert {
526526

527527
use std::fmt::Write;
528528
let mut buf = String::new();
529-
writeln!(&mut buf, "{}", desc).unwrap();
529+
writeln!(&mut buf, "{desc}").unwrap();
530530
self.write_stdout(&mut buf).unwrap();
531531
self.write_stderr(&mut buf).unwrap();
532532
panic!("{}", buf);
@@ -548,7 +548,7 @@ impl OutputAssert {
548548

549549
use std::fmt::Write;
550550
let mut buf = String::new();
551-
writeln!(&mut buf, "{}", desc).unwrap();
551+
writeln!(&mut buf, "{desc}").unwrap();
552552
self.write_stdout(&mut buf).unwrap();
553553
self.write_stderr(&mut buf).unwrap();
554554
panic!("{}", buf);
@@ -580,7 +580,7 @@ impl OutputAssert {
580580

581581
use std::fmt::Write;
582582
let mut buf = String::new();
583-
writeln!(&mut buf, "{}", desc).unwrap();
583+
writeln!(&mut buf, "{desc}").unwrap();
584584
self.write_stdout(&mut buf).unwrap();
585585
self.write_stderr(&mut buf).unwrap();
586586
panic!("{}", buf);
@@ -761,7 +761,7 @@ pub fn display_exit_status(status: std::process::ExitStatus) -> String {
761761
libc::SIGTRAP => ", SIGTRAP: trace/breakpoint trap",
762762
_ => "",
763763
};
764-
Some(format!("signal: {}{}", signal, name))
764+
Some(format!("signal: {signal}{name}"))
765765
}
766766

767767
#[cfg(windows)]
@@ -914,8 +914,7 @@ pub(crate) mod examples {
914914
}
915915

916916
Err(crate::assert::Error::new(format!(
917-
"Unknown error building example {}",
918-
target_name
917+
"Unknown error building example {target_name}"
919918
)))
920919
}
921920

crates/snapbox/src/data/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub trait ToDebug {
3838

3939
impl<D: std::fmt::Debug> ToDebug for D {
4040
fn to_debug(&self) -> Data {
41-
Data::text(format!("{:#?}\n", self))
41+
Data::text(format!("{self:#?}\n"))
4242
}
4343
}
4444

crates/snapbox/src/filter/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ mod test {
625625
];
626626
for (line, pattern, expected) in cases {
627627
let actual = line_matches(line, pattern, &Redactions::new());
628-
assert_eq!(expected, actual, "line={:?} pattern={:?}", line, pattern);
628+
assert_eq!(expected, actual, "line={line:?} pattern={pattern:?}");
629629
}
630630
}
631631
}

crates/snapbox/src/filter/redactions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,14 @@ fn replace_many<'a>(
327327

328328
fn validate_placeholder(placeholder: &'static str) -> crate::assert::Result<&'static str> {
329329
if !placeholder.starts_with('[') || !placeholder.ends_with(']') {
330-
return Err(format!("Key `{}` is not enclosed in []", placeholder).into());
330+
return Err(format!("Key `{placeholder}` is not enclosed in []").into());
331331
}
332332

333333
if placeholder[1..(placeholder.len() - 1)]
334334
.find(|c: char| !c.is_ascii_uppercase() && c != '_')
335335
.is_some()
336336
{
337-
return Err(format!("Key `{}` can only be A-Z but ", placeholder).into());
337+
return Err(format!("Key `{placeholder}` can only be A-Z but ").into());
338338
}
339339

340340
Ok(placeholder)
@@ -356,7 +356,7 @@ mod test {
356356
];
357357
for (placeholder, expected) in cases {
358358
let actual = validate_placeholder(placeholder).is_ok();
359-
assert_eq!(expected, actual, "placeholder={:?}", placeholder);
359+
assert_eq!(expected, actual, "placeholder={placeholder:?}");
360360
}
361361
}
362362
}

0 commit comments

Comments
 (0)