Commit 535e4ff1 authored by Ian Jackson's avatar Ian Jackson
Browse files

Replace manual Default and new with std derive in tor-netdoc

parent 4dfd1ef9
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -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<RsaIdentity>);

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<Self> {
+3 −9
Original line number Diff line number Diff line
@@ -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.