From e6a335b93a10620bcb7cbfa32e232949758f0c99 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 21 Sep 2021 10:23:04 +0300 Subject: Drop unnecessary lifetime notations Rust can automatically deduce lifetimes in some cases ("lifetime elision"). While adding unnecessary lifetime annotations is not incorrect, it can make it harder to follow the code: why is there a lifetime annotation here? What is the reason why it's needed? Is something unusual going on. This removes a few unnecessary lifetime annotations, as found by the clippy lint needless_lifetimes: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes --- openpgp/src/packet/container.rs | 6 +++--- openpgp/src/packet/signature/subpacket.rs | 6 +++--- openpgp/src/parse/map.rs | 2 +- openpgp/src/serialize/cert.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'openpgp') diff --git a/openpgp/src/packet/container.rs b/openpgp/src/packet/container.rs index 42634c6e..15e24a50 100644 --- a/openpgp/src/packet/container.rs +++ b/openpgp/src/packet/container.rs @@ -270,7 +270,7 @@ impl Container { /// Returns an iterator over the packet's immediate children. /// /// Returns `None` if the body is not structured. - pub fn children<'a>(&'a self) -> Option> { + pub fn children(&self) -> Option> { Some(self.children_ref()?.iter()) } @@ -435,8 +435,8 @@ impl Packet { } /// Returns an iterator over the packet's immediate children. - pub(crate) fn children<'a>(&'a self) - -> Option> { + pub(crate) fn children(& self) + -> Option> { self.container_ref().and_then(|c| c.children()) } diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index c1f7c510..f71647d5 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -2108,7 +2108,7 @@ impl SubpacketAreas { /// /// For subpackets that can safely occur in both subpacket areas, /// this function prefers instances in the hashed subpacket area. - pub fn subpacket<'a>(&'a self, tag: SubpacketTag) -> Option<&Subpacket> { + pub fn subpacket(&self, tag: SubpacketTag) -> Option<&Subpacket> { if let Some(sb) = self.hashed_area().subpacket(tag) { return Some(sb); } @@ -2141,8 +2141,8 @@ impl SubpacketAreas { /// /// For subpackets that can safely occur in both subpacket areas, /// this function prefers instances in the hashed subpacket area. - pub fn subpacket_mut<'a>(&'a mut self, tag: SubpacketTag) - -> Option<&mut Subpacket> { + pub fn subpacket_mut(&mut self, tag: SubpacketTag) + -> Option<&mut Subpacket> { if let Some(_) = self.hashed_area().subpacket(tag) { return self.hashed_area_mut().subpacket_mut(tag); } diff --git a/openpgp/src/parse/map.rs b/openpgp/src/parse/map.rs index b460deea..b0c7bbea 100644 --- a/openpgp/src/parse/map.rs +++ b/openpgp/src/parse/map.rs @@ -90,7 +90,7 @@ impl Map { /// assert_eq!(map.iter().count(), 6); /// # Ok(()) } /// ``` - pub fn iter<'a>(&'a self) -> impl Iterator> + Send + Sync { + pub fn iter(&self) -> impl Iterator + Send + Sync { Iter::new(self) } } diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs index c46e4253..b6967f02 100644 --- a/openpgp/src/serialize/cert.rs +++ b/openpgp/src/serialize/cert.rs @@ -198,7 +198,7 @@ impl Cert { /// This object writes out secret keys during serialization. /// /// [`TSK`]: crate::serialize::TSK - pub fn as_tsk<'a>(&'a self) -> TSK<'a> { + pub fn as_tsk(&self) -> TSK { TSK::new(self) } } -- cgit v1.2.3