Skip to content

Commit

Permalink
Fix clippy (nightly) warning: elided lifetime has a name
Browse files Browse the repository at this point in the history
  • Loading branch information
chifflier committed Sep 24, 2024
1 parent 43342a4 commit 7d02dc1
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/asn1_types/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'a> Any<'a> {
op: F,
) -> ParseResult<'a, T, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<T, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, T, E>,
E: From<Error>,
{
let (rem, any) = Any::from_ber(bytes).map_err(Err::convert)?;
Expand All @@ -122,7 +122,7 @@ impl<'a> Any<'a> {
op: F,
) -> ParseResult<'a, T, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<T, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, T, E>,
E: From<Error>,
{
let (rem, any) = Any::from_der(bytes).map_err(Err::convert)?;
Expand Down Expand Up @@ -339,14 +339,14 @@ pub(crate) fn parse_der_any(input: &[u8]) -> ParseResult<Any> {

impl<'a> FromBer<'a> for Any<'a> {
#[inline]
fn from_ber(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self> {
trace("Any", parse_ber_any, bytes)
}
}

impl<'a> FromDer<'a> for Any<'a> {
#[inline]
fn from_der(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self> {
trace("Any", parse_der_any, bytes)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/asn1_types/octetstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<'a> OctetString<'a> {
}

/// Get the bytes representation of the *content*
pub fn as_cow(&'a self) -> &Cow<'a, [u8]> {
pub fn as_cow(&'a self) -> &'a Cow<'a, [u8]> {
&self.data
}

Expand Down
4 changes: 2 additions & 2 deletions src/asn1_types/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn encode_relative(ids: &'_ [u64]) -> impl Iterator<Item = u8> + '_ {
impl<'a> Oid<'a> {
/// Create an OID from the ASN.1 DER encoded form. See the [module documentation](index.html)
/// for other ways to create oids.
pub const fn new(asn1: Cow<'a, [u8]>) -> Oid {
pub const fn new(asn1: Cow<'a, [u8]>) -> Oid<'a> {
Oid {
asn1,
relative: false,
Expand All @@ -125,7 +125,7 @@ impl<'a> Oid<'a> {

/// Create a relative OID from the ASN.1 DER encoded form. See the [module documentation](index.html)
/// for other ways to create relative oids.
pub const fn new_relative(asn1: Cow<'a, [u8]>) -> Oid {
pub const fn new_relative(asn1: Cow<'a, [u8]>) -> Oid<'a> {
Oid {
asn1,
relative: true,
Expand Down
8 changes: 4 additions & 4 deletions src/asn1_types/optional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ where
T: FromBer<'a>,
T: Tagged,
{
fn from_ber(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self> {
if bytes.is_empty() {
return Ok((bytes, None));
}
Expand All @@ -28,7 +28,7 @@ where
}

impl<'a> FromBer<'a> for Option<Any<'a>> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self> {
if bytes.is_empty() {
return Ok((bytes, None));
}
Expand All @@ -44,7 +44,7 @@ where
T: FromDer<'a>,
T: Tagged,
{
fn from_der(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self> {
if bytes.is_empty() {
return Ok((bytes, None));
}
Expand All @@ -62,7 +62,7 @@ where
}

impl<'a> FromDer<'a> for Option<Any<'a>> {
fn from_der(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self> {
if bytes.is_empty() {
return Ok((bytes, None));
}
Expand Down
6 changes: 3 additions & 3 deletions src/asn1_types/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ impl<'a> Sequence<'a> {
/// in one step, ensuring there are only references (and dropping the temporary sequence).
pub fn and_then<U, F, E>(self, op: F) -> ParseResult<'a, U, E>
where
F: FnOnce(Cow<'a, [u8]>) -> ParseResult<U, E>,
F: FnOnce(Cow<'a, [u8]>) -> ParseResult<'a, U, E>,
{
op(self.content)
}

/// Same as [`Sequence::from_der_and_then`], but using BER encoding (no constraints).
pub fn from_ber_and_then<U, F, E>(bytes: &'a [u8], op: F) -> ParseResult<'a, U, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<U, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, U, E>,
E: From<Error>,
{
let (rem, seq) = Sequence::from_ber(bytes).map_err(Err::convert)?;
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<'a> Sequence<'a> {
/// ```
pub fn from_der_and_then<U, F, E>(bytes: &'a [u8], op: F) -> ParseResult<'a, U, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<U, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, U, E>,
E: From<Error>,
{
let (rem, seq) = Sequence::from_der(bytes).map_err(Err::convert)?;
Expand Down
2 changes: 1 addition & 1 deletion src/asn1_types/sequence/sequence_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ where
T: FromDer<'a, E>,
E: From<Error> + Display + Debug,
{
fn from_der(bytes: &'a [u8]) -> ParseResult<Self, E> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self, E> {
trace_generic(
core::any::type_name::<Self>(),
"SequenceOf::from_der",
Expand Down
2 changes: 1 addition & 1 deletion src/asn1_types/sequence/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ where
T: FromDer<'a, E>,
E: From<Error> + Debug,
{
fn from_der(bytes: &'a [u8]) -> ParseResult<Self, E> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self, E> {
trace_generic(
core::any::type_name::<Self>(),
"Sequence::from_der",
Expand Down
6 changes: 3 additions & 3 deletions src/asn1_types/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ impl<'a> Set<'a> {
/// in one step, ensuring there are only references (and dropping the temporary set).
pub fn and_then<U, F, E>(self, op: F) -> ParseResult<'a, U, E>
where
F: FnOnce(Cow<'a, [u8]>) -> ParseResult<U, E>,
F: FnOnce(Cow<'a, [u8]>) -> ParseResult<'a, U, E>,
{
op(self.content)
}

/// Same as [`Set::from_der_and_then`], but using BER encoding (no constraints).
pub fn from_ber_and_then<U, F, E>(bytes: &'a [u8], op: F) -> ParseResult<'a, U, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<U, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, U, E>,
E: From<Error>,
{
let (rem, seq) = Set::from_ber(bytes).map_err(Err::convert)?;
Expand Down Expand Up @@ -143,7 +143,7 @@ impl<'a> Set<'a> {
/// ```
pub fn from_der_and_then<U, F, E>(bytes: &'a [u8], op: F) -> ParseResult<'a, U, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<U, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, U, E>,
E: From<Error>,
{
let (rem, seq) = Set::from_der(bytes).map_err(Err::convert)?;
Expand Down
2 changes: 1 addition & 1 deletion src/asn1_types/set/set_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ where
T: FromDer<'a, E>,
E: From<Error> + Display + Debug,
{
fn from_der(bytes: &'a [u8]) -> ParseResult<Self, E> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self, E> {
trace_generic(
core::any::type_name::<Self>(),
"SetOf::from_der",
Expand Down
4 changes: 2 additions & 2 deletions src/asn1_types/tagged/explicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'a, T, E> TaggedParser<'a, Explicit, T, E> {
op: F,
) -> ParseResult<'a, T, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<T, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, T, E>,
E: From<Error>,
{
Any::from_ber_and_then(class, tag, bytes, op)
Expand All @@ -176,7 +176,7 @@ impl<'a, T, E> TaggedParser<'a, Explicit, T, E> {
op: F,
) -> ParseResult<'a, T, E>
where
F: FnOnce(&'a [u8]) -> ParseResult<T, E>,
F: FnOnce(&'a [u8]) -> ParseResult<'a, T, E>,
E: From<Error>,
{
Any::from_der_and_then(class, tag, bytes, op)
Expand Down
4 changes: 2 additions & 2 deletions src/asn1_types/tagged/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use nom::{Err, IResult};

pub fn parse_der_tagged_explicit<'a, IntoTag, T, E>(
tag: IntoTag,
) -> impl FnMut(&'a [u8]) -> ParseResult<TaggedParser<'a, Explicit, T, E>, E>
) -> impl FnMut(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, Explicit, T, E>, E>
where
IntoTag: Into<Tag>,
TaggedParser<'a, Explicit, T, E>: FromDer<'a, E>,
Expand Down Expand Up @@ -41,7 +41,7 @@ where

pub fn parse_der_tagged_implicit<'a, IntoTag, T, E>(
tag: IntoTag,
) -> impl FnMut(&'a [u8]) -> ParseResult<TaggedParser<'a, Implicit, T, E>, E>
) -> impl FnMut(&'a [u8]) -> ParseResult<'a, TaggedParser<'a, Implicit, T, E>, E>
where
IntoTag: Into<Tag>,
// T: TryFrom<Any<'a>, Error = Error> + Tagged,
Expand Down
4 changes: 2 additions & 2 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl<'a> ToStatic for Header<'a> {
}

impl<'a> FromBer<'a> for Header<'a> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self> {
let (i1, el) = parse_identifier(bytes)?;
let class = match Class::try_from(el.0) {
Ok(c) => c,
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<'a> FromBer<'a> for Header<'a> {
}

impl<'a> FromDer<'a> for Header<'a> {
fn from_der(bytes: &'a [u8]) -> ParseResult<Self> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self> {
let (i1, el) = parse_identifier(bytes)?;
let class = match Class::try_from(el.0) {
Ok(c) => c,
Expand Down
8 changes: 4 additions & 4 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ where
/// ```
pub trait FromBer<'a, E = Error>: Sized {
/// Attempt to parse input bytes into a BER object
fn from_ber(bytes: &'a [u8]) -> ParseResult<Self, E>;
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self, E>;
}

impl<'a, T, E> FromBer<'a, E> for T
where
T: TryFrom<Any<'a>, Error = E>,
E: From<Error>,
{
fn from_ber(bytes: &'a [u8]) -> ParseResult<T, E> {
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, T, E> {
let (i, any) = Any::from_ber(bytes).map_err(nom::Err::convert)?;
let result = any.try_into().map_err(nom::Err::Error)?;
Ok((i, result))
Expand Down Expand Up @@ -154,7 +154,7 @@ where
/// ```
pub trait FromDer<'a, E = Error>: Sized {
/// Attempt to parse input bytes into a DER object (enforcing constraints)
fn from_der(bytes: &'a [u8]) -> ParseResult<Self, E>;
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self, E>;
}

/// Trait to automatically derive `FromDer`
Expand Down Expand Up @@ -182,7 +182,7 @@ where
T: DerAutoDerive,
E: From<Error> + Display + Debug,
{
fn from_der(bytes: &'a [u8]) -> ParseResult<T, E> {
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, T, E> {
trace_generic(
core::any::type_name::<T>(),
"T::from_der",
Expand Down

0 comments on commit 7d02dc1

Please sign in to comment.