Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix misc. clippy findings #65

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pub use server_name::{
/// assert!(matches!(sec1, PrivateKeyDer::Sec1(_)));
/// # }
/// ```

#[non_exhaustive]
#[derive(Debug, PartialEq, Eq)]
pub enum PrivateKeyDer<'a> {
Expand All @@ -130,7 +129,7 @@ pub enum PrivateKeyDer<'a> {
Pkcs8(PrivatePkcs8KeyDer<'a>),
}

impl<'a> PrivateKeyDer<'a> {
impl PrivateKeyDer<'_> {
/// Clone the private key to a `'static` value
#[cfg(feature = "alloc")]
pub fn clone_key(&self) -> PrivateKeyDer<'static> {
Expand Down Expand Up @@ -267,7 +266,7 @@ impl<'a> TryFrom<&'a [u8]> for PrivateKeyDer<'a> {
static INVALID_KEY_DER_ERR: &str = "unknown or invalid key format";

#[cfg(feature = "alloc")]
impl<'a> TryFrom<Vec<u8>> for PrivateKeyDer<'a> {
impl TryFrom<Vec<u8>> for PrivateKeyDer<'_> {
type Error = &'static str;

fn try_from(key: Vec<u8>) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -324,7 +323,7 @@ impl<'a> From<&'a [u8]> for PrivatePkcs1KeyDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for PrivatePkcs1KeyDer<'a> {
impl From<Vec<u8>> for PrivatePkcs1KeyDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der(BytesInner::Owned(vec)))
}
Expand Down Expand Up @@ -384,7 +383,7 @@ impl<'a> From<&'a [u8]> for PrivateSec1KeyDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for PrivateSec1KeyDer<'a> {
impl From<Vec<u8>> for PrivateSec1KeyDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der(BytesInner::Owned(vec)))
}
Expand Down Expand Up @@ -445,7 +444,7 @@ impl<'a> From<&'a [u8]> for PrivatePkcs8KeyDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for PrivatePkcs8KeyDer<'a> {
impl From<Vec<u8>> for PrivatePkcs8KeyDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der(BytesInner::Owned(vec)))
}
Expand Down Expand Up @@ -551,7 +550,7 @@ impl<'a> From<&'a [u8]> for CertificateRevocationListDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for CertificateRevocationListDer<'a> {
impl From<Vec<u8>> for CertificateRevocationListDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der::from(vec))
}
Expand Down Expand Up @@ -603,7 +602,7 @@ impl<'a> From<&'a [u8]> for CertificateSigningRequestDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for CertificateSigningRequestDer<'a> {
impl From<Vec<u8>> for CertificateSigningRequestDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der::from(vec))
}
Expand Down Expand Up @@ -671,7 +670,7 @@ impl<'a> From<&'a [u8]> for CertificateDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for CertificateDer<'a> {
impl From<Vec<u8>> for CertificateDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der::from(vec))
}
Expand Down Expand Up @@ -734,7 +733,7 @@ impl<'a> From<&'a [u8]> for SubjectPublicKeyInfoDer<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for SubjectPublicKeyInfoDer<'a> {
impl From<Vec<u8>> for SubjectPublicKeyInfoDer<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(Der::from(vec))
}
Expand Down Expand Up @@ -837,7 +836,7 @@ impl<'a> From<&'a [u8]> for EchConfigListBytes<'a> {
}

#[cfg(feature = "alloc")]
impl<'a> From<Vec<u8>> for EchConfigListBytes<'a> {
impl From<Vec<u8>> for EchConfigListBytes<'_> {
fn from(vec: Vec<u8>) -> Self {
Self(BytesInner::Owned(vec))
}
Expand Down
12 changes: 6 additions & 6 deletions src/server_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum ServerName<'a> {
IpAddress(IpAddr),
}

impl<'a> ServerName<'a> {
impl ServerName<'_> {
/// Produce an owned `ServerName` from this (potentially borrowed) `ServerName`.
#[cfg(feature = "alloc")]
pub fn to_owned(&self) -> ServerName<'static> {
Expand All @@ -78,7 +78,7 @@ impl<'a> ServerName<'a> {
}
}

impl<'a> fmt::Debug for ServerName<'a> {
impl fmt::Debug for ServerName<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::DnsName(d) => f.debug_tuple("DnsName").field(&d.as_ref()).finish(),
Expand Down Expand Up @@ -233,7 +233,7 @@ impl<'a> TryFrom<&'a [u8]> for DnsName<'a> {
}
}

impl<'a> AsRef<str> for DnsName<'a> {
impl AsRef<str> for DnsName<'_> {
fn as_ref(&self) -> &str {
match self {
Self(DnsNameInner::Borrowed(s)) => s,
Expand All @@ -250,7 +250,7 @@ enum DnsNameInner<'a> {
Owned(String),
}

impl<'a> PartialEq<Self> for DnsNameInner<'a> {
impl PartialEq<Self> for DnsNameInner<'_> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Borrowed(s), Self::Borrowed(o)) => s.eq_ignore_ascii_case(o),
Expand All @@ -264,7 +264,7 @@ impl<'a> PartialEq<Self> for DnsNameInner<'a> {
}
}

impl<'a> Hash for DnsNameInner<'a> {
impl Hash for DnsNameInner<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
let s = match self {
Self::Borrowed(s) => s,
Expand All @@ -276,7 +276,7 @@ impl<'a> Hash for DnsNameInner<'a> {
}
}

impl<'a> fmt::Debug for DnsNameInner<'a> {
impl fmt::Debug for DnsNameInner<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Borrowed(s) => f.write_fmt(format_args!("{:?}", s)),
Expand Down
2 changes: 1 addition & 1 deletion tests/pem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,5 @@ fn slice_iterator() {
CertificateDer::from(&b"hi"[..])
);
assert_eq!(iter.remainder(), b"goodbye\n");
assert!(matches!(iter.next(), None));
assert!(iter.next().is_none());
}