summaryrefslogtreecommitdiff
path: root/src/bindings.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-02-11 14:33:17 +0200
committerLars Wirzenius <liw@liw.fi>2023-02-11 14:33:17 +0200
commit78325817028096ca134b7c2bbd3bc6ca000a8f3e (patch)
treeb373d1d9d781f16825bc91748978b5b49ac36879 /src/bindings.rs
parentb6df0fa5b7046bad97f63dc928a9776cecaee623 (diff)
downloadsubplot-78325817028096ca134b7c2bbd3bc6ca000a8f3e.tar.gz
chore: use variables in Rust format strings
Change this: format!("{}", foo) into this: format!("{foo}") Support for this feature was added in Rust 1.58 (see https://github.com/rust-lang/rust/releases/tag/1.58.0) and in 1.67 clippy suggests about this. Because the new style seems to be where the Rust ecosystem is going, I think Subplot should follow to avoid being needlessly different from most other projects. Sponsored-by: author
Diffstat (limited to 'src/bindings.rs')
-rw-r--r--src/bindings.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/bindings.rs b/src/bindings.rs
index 98379c9..2738aa1 100644
--- a/src/bindings.rs
+++ b/src/bindings.rs
@@ -176,7 +176,7 @@ impl Binding {
case_sensitive: bool,
mut types: HashMap<String, CaptureType>,
) -> Result<Binding, SubplotError> {
- let regex = RegexBuilder::new(&format!("^{}$", pattern))
+ let regex = RegexBuilder::new(&format!("^{pattern}$"))
.case_insensitive(!case_sensitive)
.build()
.map_err(|err| SubplotError::Regex(pattern.to_string(), err))?;
@@ -541,12 +541,12 @@ fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding, SubplotError> {
let then: i32 = parsed.then.is_some().into();
if given + when + then == 0 {
- let msg = format!("{:?}", parsed);
+ let msg = format!("{parsed:?}");
return Err(SubplotError::BindingWithoutKnownKeyword(msg));
}
if given + when + then > 1 {
- let msg = format!("{:?}", parsed);
+ let msg = format!("{parsed:?}");
return Err(SubplotError::BindingHasManyKeywords(msg));
}
@@ -557,7 +557,7 @@ fn from_hashmap(parsed: &ParsedBinding) -> Result<Binding, SubplotError> {
} else if parsed.then.is_some() {
(StepKind::Then, parsed.then.as_ref().unwrap())
} else {
- let msg = format!("{:?}", parsed);
+ let msg = format!("{parsed:?}");
return Err(SubplotError::BindingWithoutKnownKeyword(msg));
};
@@ -641,7 +641,7 @@ mod test_bindings {
";
let mut bindings = Bindings::new();
bindings.add_from_yaml(yaml).unwrap();
- println!("test: {:?}", bindings);
+ println!("test: {bindings:?}");
assert!(bindings.has(StepKind::Given, "I am Tomjon"));
assert!(bindings.has(StepKind::When, "I declare myself king"));
assert!(bindings.has(StepKind::Then, "there is applause"));