diff --git a/src/captured.rs b/src/captured.rs index 80360f0..3c5923c 100644 --- a/src/captured.rs +++ b/src/captured.rs @@ -269,7 +269,7 @@ impl From for CapturedBuilder { struct CapturedWriter<'a>(&'a mut BytesMut); -impl<'a> io::Write for CapturedWriter<'a> { +impl io::Write for CapturedWriter<'_> { fn write(&mut self, buf: &[u8]) -> Result { self.0.extend_from_slice(buf); Ok(buf.len()) diff --git a/src/decode/source.rs b/src/decode/source.rs index cb4c0c1..765d225 100644 --- a/src/decode/source.rs +++ b/src/decode/source.rs @@ -136,7 +136,7 @@ pub trait Source { } } -impl<'a, T: Source> Source for &'a mut T { +impl Source for &'_ mut T { type Error = T::Error; fn request(&mut self, len: usize) -> Result { @@ -340,7 +340,7 @@ impl<'a> SliceSource<'a> { } } -impl<'a> Source for SliceSource<'a> { +impl Source for SliceSource<'_> { type Error = Infallible; fn pos(&self) -> Pos { diff --git a/src/encode/primitive.rs b/src/encode/primitive.rs index b2d876d..f6db093 100644 --- a/src/encode/primitive.rs +++ b/src/encode/primitive.rs @@ -79,7 +79,7 @@ pub trait PrimitiveContent: Sized { //--- Blanket impls -impl<'a, T: PrimitiveContent> PrimitiveContent for &'a T { +impl PrimitiveContent for &'_ T { const TAG: Tag = T::TAG; fn encoded_len(&self, mode: Mode) -> usize { @@ -323,7 +323,7 @@ impl PrimitiveContent for bool { } } -impl<'a> PrimitiveContent for &'a [u8] { +impl PrimitiveContent for &'_ [u8] { const TAG: Tag = Tag::OCTET_STRING; fn encoded_len(&self, _: Mode) -> usize { diff --git a/src/encode/values.rs b/src/encode/values.rs index e541525..5918c99 100644 --- a/src/encode/values.rs +++ b/src/encode/values.rs @@ -55,7 +55,7 @@ pub trait Values { //--- Blanket impls -impl<'a, T: Values> Values for &'a T { +impl Values for &'_ T { fn encoded_len(&self, mode: Mode) -> usize { (*self).encoded_len(mode) } @@ -358,7 +358,7 @@ impl IntoIterator for Iter { } } -impl<'a, T: Clone + IntoIterator> IntoIterator for &'a Iter { +impl IntoIterator for &'_ Iter { type Item = ::Item; type IntoIter = ::IntoIter; diff --git a/src/int.rs b/src/int.rs index 22e0b44..70242b0 100644 --- a/src/int.rs +++ b/src/int.rs @@ -397,7 +397,7 @@ impl hash::Hash for Integer { //--- encode::PrimitiveContent -impl<'a> PrimitiveContent for &'a Integer { +impl PrimitiveContent for &'_ Integer { const TAG: Tag = Tag::INTEGER; fn encoded_len(&self, _mode: Mode) -> usize { @@ -528,7 +528,7 @@ impl Unsigned { 1 => Ok(prim.take_u8()?.into()), 2 => { Ok( - u16::from(prim.take_u8()?) << 8 | + (u16::from(prim.take_u8()?) << 8) | u16::from(prim.take_u8()?) ) } @@ -537,7 +537,7 @@ impl Unsigned { return Err(prim.content_err("invalid integer")) } let res = { - u16::from(prim.take_u8()?) << 8 | + (u16::from(prim.take_u8()?) << 8) | u16::from(prim.take_u8()?) }; if res < 0x8000 { @@ -654,7 +654,7 @@ impl AsRef<[u8]> for Unsigned { //--- endode::PrimitiveContent -impl<'a> PrimitiveContent for &'a Unsigned { +impl PrimitiveContent for &'_ Unsigned { const TAG: Tag = Tag::INTEGER; fn encoded_len(&self, mode: Mode) -> usize { diff --git a/src/length.rs b/src/length.rs index f6b15e3..0c2e90e 100644 --- a/src/length.rs +++ b/src/length.rs @@ -75,7 +75,7 @@ impl Length { } 0x82 => { let len = - (source.take_u8()? as usize) << 8 | + ((source.take_u8()? as usize) << 8) | (source.take_u8()? as usize); if mode.is_ber() || len > 255 { Ok(Length::Definite(len)) @@ -86,8 +86,8 @@ impl Length { } 0x83 => { let len = - (source.take_u8()? as usize) << 16 | - (source.take_u8()? as usize) << 8 | + ((source.take_u8()? as usize) << 16) | + ((source.take_u8()? as usize) << 8) | (source.take_u8()? as usize); if mode.is_ber() || len > 0xFFFF { Ok(Length::Definite(len)) @@ -98,9 +98,9 @@ impl Length { } 0x84 => { let len = - (source.take_u8()? as usize) << 24 | - (source.take_u8()? as usize) << 16 | - (source.take_u8()? as usize) << 8 | + ((source.take_u8()? as usize) << 24) | + ((source.take_u8()? as usize) << 16) | + ((source.take_u8()? as usize) << 8) | (source.take_u8()? as usize); if mode.is_ber() || len > 0x00FF_FFFF { Ok(Length::Definite(len)) diff --git a/src/oid.rs b/src/oid.rs index a37c91a..46c93e0 100644 --- a/src/oid.rs +++ b/src/oid.rs @@ -370,7 +370,7 @@ impl<'a> Component<'a> { } let mut res = 0; for &ch in self.slice { - res = res << 7 | u32::from(ch & 0x7F); + res = (res << 7) | u32::from(ch & 0x7F); } match self.position { Position::First => { @@ -400,18 +400,18 @@ impl<'a> Component<'a> { //--- PartialEq and Eq -impl<'a> PartialEq for Component<'a> { +impl PartialEq for Component<'_> { fn eq(&self, other: &Self) -> bool { self.position == other.position && self.slice == other.slice } } -impl<'a> Eq for Component<'a> { } +impl Eq for Component<'_> { } //--- Display -impl<'a> fmt::Display for Component<'a> { +impl fmt::Display for Component<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // XXX This can’t deal correctly with overly large components. // Since this is a really rare (if not non-existant) case, diff --git a/src/string/bit.rs b/src/string/bit.rs index 3b1f8c5..8af4735 100644 --- a/src/string/bit.rs +++ b/src/string/bit.rs @@ -275,7 +275,7 @@ impl encode::PrimitiveContent for BitString { #[derive(Clone, Debug)] pub struct BitStringIter<'a>(::std::slice::Iter<'a, u8>); -impl<'a> Iterator for BitStringIter<'a> { +impl Iterator for BitStringIter<'_> { type Item = u8; fn next(&mut self) -> Option { diff --git a/src/string/octet.rs b/src/string/octet.rs index a0c7cfc..1bcae52 100644 --- a/src/string/octet.rs +++ b/src/string/octet.rs @@ -678,16 +678,12 @@ impl<'a> OctetStringOctets<'a> { } } -impl<'a> Iterator for OctetStringOctets<'a> { +impl Iterator for OctetStringOctets<'_> { type Item = u8; fn next(&mut self) -> Option { while self.cur.is_empty() { - let next = match self.iter.next() { - Some(some) => some, - None => return None, - }; - self.cur = next; + self.cur = self.iter.next()?; } let res = self.cur[0]; self.cur = &self.cur[1..]; diff --git a/src/string/restricted.rs b/src/string/restricted.rs index 096bbe1..7709f37 100644 --- a/src/string/restricted.rs +++ b/src/string/restricted.rs @@ -308,7 +308,7 @@ impl<'a, L: CharSet> RestrictedStringChars<'a, L> { } } -impl<'a, L: CharSet> Iterator for RestrictedStringChars<'a, L> { +impl Iterator for RestrictedStringChars<'_, L> { type Item = char; fn next(&mut self) -> Option { @@ -361,7 +361,7 @@ impl CharSet for Utf8CharSet { if first < 0xE0 { return Ok(Some(unsafe { char::from_u32_unchecked( - (u32::from(first & 0x1F)) << 6 | + ((u32::from(first & 0x1F)) << 6) | u32::from(second & 0x3F) ) })) @@ -376,8 +376,8 @@ impl CharSet for Utf8CharSet { if first < 0xF0 { return Ok(Some(unsafe { char::from_u32_unchecked( - (u32::from(first & 0x0F)) << 12 | - (u32::from(second & 0x3F)) << 6 | + ((u32::from(first & 0x0F)) << 12) | + ((u32::from(second & 0x3F)) << 6) | u32::from(third & 0x3F) ) })) @@ -391,9 +391,9 @@ impl CharSet for Utf8CharSet { } Ok(Some(unsafe { char::from_u32_unchecked( - (u32::from(first & 0x07)) << 18 | - (u32::from(second & 0x3F)) << 12 | - (u32::from(third & 0x3F)) << 6 | + ((u32::from(first & 0x07)) << 18) | + ((u32::from(second & 0x3F)) << 12) | + ((u32::from(third & 0x3F)) << 6) | u32::from(fourth & 0x3F) ) })) diff --git a/src/tag.rs b/src/tag.rs index 04125aa..5e3cbb1 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -351,12 +351,12 @@ impl Tag { } else if Tag::LAST_OCTET_MASK & self.0[2] == 0 { // It's a multibyte that starts in the second octet and ends in // the third octet - u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[1]) << 7 + (u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[1]) << 7) | u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[2]) } else { // It's a multibyte that spans the first three octets - u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[1]) << 14 - | u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[2]) << 7 + (u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[1]) << 14) + | (u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[2]) << 7) | u32::from(Tag::MULTIBYTE_DATA_MASK & self.0[3]) } }