Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: simplify statements for readability #119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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