Skip to content

Commit

Permalink
Merge simplify-statements-for-readability branch
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Feb 14, 2025
2 parents 2134037 + e8866da commit 93f105d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/add_anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ fn main() {
pf.try_add_anchor(&anchor_name, pfctl::AnchorKind::Scrub)
.expect("Unable to add scrub anchor");

println!("Added {} as every anchor type", anchor_name);
println!("Added {anchor_name} as every anchor type");
}
}
4 changes: 2 additions & 2 deletions examples/add_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn main() {
pf.add_scrub_rule(ANCHOR_NAME, &scrub_rule)
.expect("Unable to add scrub rule");

println!("Added a bunch of rules to the {} anchor.", ANCHOR_NAME);
println!("Added a bunch of rules to the {ANCHOR_NAME} anchor.");
println!("Run this command to remove them:");
println!("sudo pfctl -a {} -F all", ANCHOR_NAME);
println!("sudo pfctl -a {ANCHOR_NAME} -F all");
}
8 changes: 4 additions & 4 deletions examples/flush_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ fn main() {
for anchor_name in env::args().skip(1) {
pf.flush_rules(&anchor_name, pfctl::RulesetKind::Filter)
.expect("Unable to flush filter rules");
println!("Flushed filter rules under anchor {}", anchor_name);
println!("Flushed filter rules under anchor {anchor_name}");

pf.flush_rules(&anchor_name, pfctl::RulesetKind::Nat)
.expect("Unable to flush nat rules");
println!("Flushed nat rules under anchor {}", anchor_name);
println!("Flushed nat rules under anchor {anchor_name}");

pf.flush_rules(&anchor_name, pfctl::RulesetKind::Redirect)
.expect("Unable to flush redirect rules");
println!("Flushed redirect rules under anchor {}", anchor_name);
println!("Flushed redirect rules under anchor {anchor_name}");

pf.flush_rules(&anchor_name, pfctl::RulesetKind::Scrub)
.expect("Unable to flush scrub rules");
println!("Flushed scrub rules under anchor {}", anchor_name);
println!("Flushed scrub rules under anchor {anchor_name}");
}
}
4 changes: 2 additions & 2 deletions examples/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn main() {
pf.set_rules(ANCHOR_NAME, trans_change)
.expect("Unable to set rules");

println!("Added a bunch of rules to the {} anchor.", ANCHOR_NAME);
println!("Added a bunch of rules to the {ANCHOR_NAME} anchor.");
println!("Run this command to remove them:");
println!("sudo pfctl -a {} -F all", ANCHOR_NAME);
println!("sudo pfctl -a {ANCHOR_NAME} -F all");
}
8 changes: 3 additions & 5 deletions src/rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ impl FilterRule {
| (StatePolicy::Modulate, Proto::Tcp)
| (StatePolicy::SynProxy, Proto::Tcp) => Ok(self.keep_state),
(state_policy, proto) => {
let msg = format!(
"StatePolicy {:?} and protocol {:?} are incompatible",
state_policy, proto
);
let msg =
format!("StatePolicy {state_policy:?} and protocol {proto:?} are incompatible");
Err(Error::from(ErrorInternal::InvalidRuleCombination(msg)))
}
}
Expand Down Expand Up @@ -360,7 +358,7 @@ fn compatible_af(af1: AddrFamily, af2: AddrFamily) -> Result<AddrFamily> {
(af, AddrFamily::Any) => Ok(af),
(AddrFamily::Any, af) => Ok(af),
(af1, af2) => {
let msg = format!("AddrFamily {} and {} are incompatible", af1, af2);
let msg = format!("AddrFamily {af1} and {af2} are incompatible");
Err(Error::from(ErrorInternal::InvalidRuleCombination(msg)))
}
}
Expand Down

0 comments on commit 93f105d

Please sign in to comment.