summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-12-03 12:18:15 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2021-12-03 15:07:59 +0100
commit34bf61a959efff8b1876c24bc5e7f058ec45fefe (patch)
tree406a7159fbcda73fe80bd664925fadf458b7d6fe /openpgp
parent98491a207c6401b158103ae95e9abb85157025cd (diff)
openpgp: Derive Default.
- Replace manual implementations of Default where the derive(Default) is identical. - Suggested by clippy, https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impl
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/cert/parser/mod.rs13
-rw-r--r--openpgp/src/packet/marker.rs10
-rw-r--r--openpgp/src/packet/mod.rs10
-rw-r--r--openpgp/src/parse.rs10
4 files changed, 4 insertions, 39 deletions
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs
index 53c9bcf9..0b48736b 100644
--- a/openpgp/src/cert/parser/mod.rs
+++ b/openpgp/src/cert/parser/mod.rs
@@ -480,6 +480,7 @@ impl CertValidator {
/// # }
/// ```
+#[derive(Default)]
pub struct CertParser<'a> {
source: Option<Box<dyn Iterator<Item=Result<Packet>> + 'a + Send + Sync>>,
packets: Vec<Packet>,
@@ -489,18 +490,6 @@ pub struct CertParser<'a> {
}
assert_send_and_sync!(CertParser<'_>);
-impl<'a> Default for CertParser<'a> {
- fn default() -> Self {
- CertParser {
- source: None,
- packets: vec![],
- queued_error: None,
- saw_error: false,
- filter: vec![],
- }
- }
-}
-
// When using a `PacketParser`, we never use the `Iter` variant.
// Nevertheless, we need to provide a concrete type.
// vec::IntoIter<Packet> is about as good as any other.
diff --git a/openpgp/src/packet/marker.rs b/openpgp/src/packet/marker.rs
index f8b84842..edeb03ae 100644
--- a/openpgp/src/packet/marker.rs
+++ b/openpgp/src/packet/marker.rs
@@ -11,7 +11,7 @@ use crate::Packet;
/// [Section 5.8 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.8
// IMPORTANT: If you add fields to this struct, you need to explicitly
// IMPORTANT: implement PartialEq, Eq, and Hash.
-#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Default, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Marker {
/// CTB packet header fields.
pub(crate) common: packet::Common,
@@ -22,14 +22,6 @@ impl Marker {
pub(crate) const BODY: &'static [u8] = &[0x50, 0x47, 0x50];
}
-impl Default for Marker {
- fn default() -> Self {
- Self {
- common: Default::default(),
- }
- }
-}
-
impl From<Marker> for Packet {
fn from(p: Marker) -> Self {
Packet::Marker(p)
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs
index b39af8e8..4e3b344c 100644
--- a/openpgp/src/packet/mod.rs
+++ b/openpgp/src/packet/mod.rs
@@ -553,7 +553,7 @@ impl Arbitrary for Packet {
}
/// Fields used by multiple packet types.
-#[derive(Debug, Clone)]
+#[derive(Default, Debug, Clone)]
pub struct Common {
// In the future, this structure will hold the parsed CTB, packet
// length, and lengths of chunks of partial body encoded packets.
@@ -579,14 +579,6 @@ impl Arbitrary for Common {
}
}
-impl Default for Common {
- fn default() -> Common {
- Common {
- dummy: Default::default(),
- }
- }
-}
-
impl PartialEq for Common {
fn eq(&self, _: &Common) -> bool {
// Don't compare anything.
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 36e28eb3..1fe8899d 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -728,6 +728,7 @@ assert_send_and_sync!(Cookie);
/// Contains hashes for consecutive one pass signature packets ending
/// in one with the last flag set.
+#[derive(Default)]
pub(crate) struct SignatureGroup {
/// Counts the number of one pass signature packets this group is
/// for. Once this drops to zero, we pop the group from the
@@ -833,15 +834,6 @@ impl fmt::Debug for SignatureGroup {
}
}
-impl Default for SignatureGroup {
- fn default() -> Self {
- SignatureGroup {
- ops_count: 0,
- hashes: Default::default(),
- }
- }
-}
-
impl SignatureGroup {
/// Clears the signature group.
fn clear(&mut self) {