diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-27 09:04:34 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2021-09-30 08:31:07 +0300 |
commit | 85362f33d81ebdc1cd355454be2494b9286e80be (patch) | |
tree | 6fba218d7f81565e0dd7f00883d8ab908e958af0 /store | |
parent | 9fdbbf44d55f99807b2d2736ed3a85b0517be8e7 (diff) |
Avoid naming field setting it from variable of the same name
When creating a struct with a field foo, using a variable also named
foo, it's not necessary to name the field explicitly. Thus, instead
of:
Self { foo: foo }
use this:
Self { foo }
The shorter form is more idiomatic and thus less confusing to
experienced Rust programmers.
This was found by the clippy lint redundant_field_names:
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
Sponsored-by: author
Diffstat (limited to 'store')
-rw-r--r-- | store/src/backend/log.rs | 2 | ||||
-rw-r--r-- | store/src/backend/mod.rs | 16 | ||||
-rw-r--r-- | store/src/lib.rs | 32 |
3 files changed, 25 insertions, 25 deletions
diff --git a/store/src/backend/log.rs b/store/src/backend/log.rs index 722b51c3..10fc2e88 100644 --- a/store/src/backend/log.rs +++ b/store/src/backend/log.rs @@ -84,7 +84,7 @@ pub struct IterServer { impl IterServer { pub fn new(c: Rc<Connection>, selector: Selector) -> Self { - IterServer{c: c, selector: selector, n: ID::max()} + IterServer{c, selector, n: ID::max()} } } diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs index 4b2db1be..54bb1708 100644 --- a/store/src/backend/mod.rs +++ b/store/src/backend/mod.rs @@ -281,7 +281,7 @@ impl Query for MappingServer { impl MappingServer { fn new(c: Rc<Connection>, id: ID) -> MappingServer { - MappingServer{c: c, id: id} + MappingServer{c, id} } fn open(c: Rc<Connection>, realm: &str, policy: net::Policy, name: &str) @@ -423,8 +423,8 @@ struct BindingServer { impl BindingServer { fn new(c: Rc<Connection>, id: ID) -> Self { BindingServer { - c: c, - id: id, + c, + id, } } @@ -691,8 +691,8 @@ struct KeyServer { impl KeyServer { fn new(c: Rc<Connection>, id: ID) -> Self { KeyServer { - c: c, - id: id, + c, + id, } } @@ -1088,7 +1088,7 @@ struct MappingIterServer { impl MappingIterServer { fn new(c: Rc<Connection>, prefix: &str) -> Self { - MappingIterServer{c: c, prefix: String::from(prefix) + "%", n: ID::null()} + MappingIterServer{c, prefix: String::from(prefix) + "%", n: ID::null()} } } @@ -1132,7 +1132,7 @@ struct BundleIterServer { impl BundleIterServer { fn new(c: Rc<Connection>, mapping_id: ID) -> Self { - BundleIterServer{c: c, mapping_id: mapping_id, n: ID::null()} + BundleIterServer{c, mapping_id, n: ID::null()} } } @@ -1168,7 +1168,7 @@ struct KeyIterServer { impl KeyIterServer { fn new(c: Rc<Connection>) -> Self { - KeyIterServer{c: c, n: ID::null()} + KeyIterServer{c, n: ID::null()} } } diff --git a/store/src/lib.rs b/store/src/lib.rs index b4ce17b3..962bce83 100644 --- a/store/src/lib.rs +++ b/store/src/lib.rs @@ -291,7 +291,7 @@ impl Store { let (mut core, client) = Store::connect(c)?; let request = client.iter_keys_request(); let iter = make_request!(&mut core, request)?; - Ok(KeyIter{core: Rc::new(RefCell::new(core)), iter: iter}) + Ok(KeyIter{core: Rc::new(RefCell::new(core)), iter}) } /// Lists all log entries. @@ -299,7 +299,7 @@ impl Store { let (mut core, client) = Store::connect(c)?; let request = client.log_request(); let iter = make_request!(&mut core, request)?; - Ok(LogIter{core: Rc::new(RefCell::new(core)), iter: iter}) + Ok(LogIter{core: Rc::new(RefCell::new(core)), iter}) } } @@ -343,7 +343,7 @@ impl Mapping { } fn new(core: Rc<RefCell<RpcRuntime>>, name: &str, mapping: node::mapping::Client) -> Self { - Mapping{core: core, name: name.into(), mapping: mapping} + Mapping{core, name: name.into(), mapping} } /// Lists all mappings with the given prefix. @@ -352,7 +352,7 @@ impl Mapping { let mut request = client.iter_request(); request.get().set_realm_prefix(realm_prefix); let iter = make_request!(&mut core, request)?; - Ok(MappingIter{core: Rc::new(RefCell::new(core)), iter: iter}) + Ok(MappingIter{core: Rc::new(RefCell::new(core)), iter}) } /// Adds a key identified by fingerprint to the mapping. @@ -536,14 +536,14 @@ impl Mapping { pub fn iter(&self) -> Result<BundleIter> { let request = self.mapping.iter_request(); let iter = make_request!(self.core.borrow_mut(), request)?; - Ok(BundleIter{core: self.core.clone(), iter: iter}) + Ok(BundleIter{core: self.core.clone(), iter}) } /// Lists all log entries related to this mapping. pub fn log(&self) -> Result<LogIter> { let request = self.mapping.log_request(); let iter = make_request!(self.core.borrow_mut(), request)?; - Ok(LogIter{core: self.core.clone(), iter: iter}) + Ok(LogIter{core: self.core.clone(), iter}) } } @@ -588,7 +588,7 @@ impl Binding { fn new(core: Rc<RefCell<RpcRuntime>>, label: Option<&str>, binding: node::binding::Client) -> Self { - Binding{label: label.map(|l| l.into()), core: core, binding: binding} + Binding{label: label.map(|l| l.into()), core, binding} } /// Returns stats for this binding. @@ -799,7 +799,7 @@ impl Binding { pub fn log(&self) -> Result<LogIter> { let request = self.binding.log_request(); let iter = make_request!(self.core.borrow_mut(), request)?; - Ok(LogIter{core: self.core.clone(), iter: iter}) + Ok(LogIter{core: self.core.clone(), iter}) } /// Gets this binding's label. @@ -832,7 +832,7 @@ impl fmt::Debug for Key { impl Key { fn new(core: Rc<RefCell<RpcRuntime>>, key: node::key::Client) -> Self { - Key{core: core, key: key} + Key{core, key} } /// Returns the Cert. @@ -904,7 +904,7 @@ impl Key { pub fn log(&self) -> Result<LogIter> { let request = self.key.log_request(); let iter = make_request!(self.core.borrow_mut(), request)?; - Ok(LogIter{core: self.core.clone(), iter: iter}) + Ok(LogIter{core: self.core.clone(), iter}) } } @@ -975,10 +975,10 @@ impl Log { let timestamp = from_unix(timestamp)?; Some(Log{ - timestamp: timestamp, - mapping: mapping, - binding: binding, - key: key, + timestamp, + mapping, + binding, + key, slug: slug.into(), status: if let Some(error) = error { Err((message.into(), error.into())) @@ -1024,8 +1024,8 @@ impl Stamps { last: Option<time::SystemTime>) -> Self { Stamps { count: count as usize, - first: first, - last: last, + first, + last, } } } |