-
Notifications
You must be signed in to change notification settings - Fork 62
Fix clippy warnings on illumos #1847
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,38 +24,38 @@ use oxide_vpc::api::ProtoFilter; | |
| use oxide_vpc::api::Protocol; | ||
|
|
||
| trait FromVpcFirewallRule { | ||
| fn action(self: &Self) -> Action; | ||
| fn direction(self: &Self) -> Direction; | ||
| fn disabled(self: &Self) -> bool; | ||
| fn hosts(self: &Self) -> Vec<Address>; | ||
| fn ports(self: &Self) -> Ports; | ||
| fn priority(self: &Self) -> u16; | ||
| fn protos(self: &Self) -> Vec<ProtoFilter>; | ||
| fn action(&self) -> Action; | ||
| fn direction(&self) -> Direction; | ||
| fn disabled(&self) -> bool; | ||
| fn hosts(&self) -> Vec<Address>; | ||
| fn ports(&self) -> Ports; | ||
| fn priority(&self) -> u16; | ||
| fn protos(&self) -> Vec<ProtoFilter>; | ||
| } | ||
|
|
||
| impl FromVpcFirewallRule for VpcFirewallRule { | ||
| fn action(self: &Self) -> Action { | ||
| fn action(&self) -> Action { | ||
| match self.action { | ||
| VpcFirewallRuleAction::Allow => Action::Allow, | ||
| VpcFirewallRuleAction::Deny => Action::Deny, | ||
| } | ||
| } | ||
|
|
||
| fn direction(self: &Self) -> Direction { | ||
| fn direction(&self) -> Direction { | ||
| match self.direction { | ||
| VpcFirewallRuleDirection::Inbound => Direction::In, | ||
| VpcFirewallRuleDirection::Outbound => Direction::Out, | ||
| } | ||
| } | ||
|
|
||
| fn disabled(self: &Self) -> bool { | ||
| fn disabled(&self) -> bool { | ||
| match self.status { | ||
| VpcFirewallRuleStatus::Disabled => false, | ||
| VpcFirewallRuleStatus::Enabled => true, | ||
| } | ||
| } | ||
|
|
||
| fn hosts(self: &Self) -> Vec<Address> { | ||
| fn hosts(&self) -> Vec<Address> { | ||
| self.filter_hosts.as_ref().map_or_else( | ||
| || vec![Address::Any], | ||
| |hosts| { | ||
|
|
@@ -78,7 +78,7 @@ impl FromVpcFirewallRule for VpcFirewallRule { | |
| ) | ||
| } | ||
|
|
||
| fn ports(self: &Self) -> Ports { | ||
| fn ports(&self) -> Ports { | ||
| match self.filter_ports { | ||
| Some(ref ports) if ports.len() > 0 => Ports::PortList( | ||
| ports | ||
|
|
@@ -125,6 +125,7 @@ pub fn opte_firewall_rules( | |
| vni: &Vni, | ||
| mac: &MacAddr6, | ||
| ) -> Vec<FirewallRule> { | ||
| #[allow(clippy::map_flatten)] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Justification: the structure of this whole loop is that we accumulate a doubly nested vector of translated rules (one for each host and protocol) and then flatten it twice to get a single vector that covers everything. If we wrote the flattening as
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds reasonable. I'd consider a comment explaining that (even if it's just "Clippy doesn't like |
||
| rules | ||
| .iter() | ||
| .filter(|rule| rule.disabled()) | ||
|
|
@@ -154,8 +155,8 @@ pub fn opte_firewall_rules( | |
| filters: { | ||
| let mut filters = Filters::new(); | ||
| filters | ||
| .set_hosts(hosts.clone()) | ||
| .set_protocol(proto.clone()) | ||
| .set_hosts(*hosts) | ||
| .set_protocol(*proto) | ||
| .set_ports(ports.clone()); | ||
| filters | ||
| }, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.