diff --git a/crates/tor-netdoc/src/types/family.rs b/crates/tor-netdoc/src/types/family.rs index 54012b08c..0b25c5d12 100644 --- a/crates/tor-netdoc/src/types/family.rs +++ b/crates/tor-netdoc/src/types/family.rs @@ -19,13 +19,13 @@ use tor_llcrypto::pk::rsa::RsaIdentity; /// entries, including entries that are only nicknames. /// /// TODO: This type probably belongs in a different crate. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct RelayFamily(Vec); impl RelayFamily { /// Return a new empty RelayFamily. pub fn new() -> Self { - RelayFamily(Vec::new()) + RelayFamily::default() } /// Does this family include the given relay? @@ -40,12 +40,6 @@ impl RelayFamily { } } -impl Default for RelayFamily { - fn default() -> Self { - RelayFamily::new() - } -} - impl std::str::FromStr for RelayFamily { type Err = Error; fn from_str(s: &str) -> Result { diff --git a/crates/tor-netdoc/src/types/policy/addrpolicy.rs b/crates/tor-netdoc/src/types/policy/addrpolicy.rs index cccae55cc..d720b5349 100644 --- a/crates/tor-netdoc/src/types/policy/addrpolicy.rs +++ b/crates/tor-netdoc/src/types/policy/addrpolicy.rs @@ -32,7 +32,7 @@ use super::{PolicyError, PortRange}; /// accept *:9000-65535 /// reject *:* /// ``` -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct AddrPolicy { /// A list of rules to apply to find out whether an address is /// contained by this policy. @@ -74,14 +74,14 @@ impl AddrPolicy { /// Create a new AddrPolicy that matches nothing. pub fn new() -> Self { - AddrPolicy { rules: Vec::new() } + AddrPolicy::default() } /// Add a new rule to this policy. /// /// The newly added rule is applied _after_ all previous rules. /// It matches all addresses and ports covered by AddrPortPattern. - /// + ///nn /// If accept is true, the rule is to accept addresses that match; /// if accept is false, the rule rejects such addresses. pub fn push(&mut self, kind: RuleKind, pattern: AddrPortPattern) { @@ -89,12 +89,6 @@ impl AddrPolicy { } } -impl Default for AddrPolicy { - fn default() -> Self { - AddrPolicy::new() - } -} - /// A single rule in an address policy. /// /// Contains a pattern and what to do with things that match it.