aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2022-03-02 17:53:28 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2022-03-02 18:01:08 +0000
commit535e4ff118d1f0ef7d2d4e29810dc3cd35329315 (patch)
treed5d3a5cfd5cd5dadda3fbb97dee71dfaf22c4431
parent4dfd1ef9cd41bdcab221445a558c9991c52f937d (diff)
downloadarti-535e4ff118d1f0ef7d2d4e29810dc3cd35329315.tar.gz
arti-535e4ff118d1f0ef7d2d4e29810dc3cd35329315.zip
Replace manual Default and new with std derive in tor-netdoc
-rw-r--r--crates/tor-netdoc/src/types/family.rs10
-rw-r--r--crates/tor-netdoc/src/types/policy/addrpolicy.rs12
2 files changed, 5 insertions, 17 deletions
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<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> {
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.