Fix clippy errors

This commit is contained in:
Igor Katson 2024-12-03 20:40:02 +00:00
parent a728b6666c
commit 438e164ffd
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
15 changed files with 36 additions and 36 deletions

View file

@ -14,7 +14,7 @@ where
{ {
struct Wrapper<'a>(&'a [u8]); struct Wrapper<'a>(&'a [u8]);
impl<'a> Serialize for Wrapper<'a> { impl Serialize for Wrapper<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
S: serde::Serializer, S: serde::Serializer,

View file

@ -202,7 +202,7 @@ impl serde::de::Error for Error {
} }
} }
impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut BencodeDeserializer<'de> { impl<'de> serde::de::Deserializer<'de> for &mut BencodeDeserializer<'de> {
type Error = Error; type Error = Error;
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error> fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
@ -517,7 +517,7 @@ struct SeqAccess<'a, 'de> {
de: &'a mut BencodeDeserializer<'de>, de: &'a mut BencodeDeserializer<'de>,
} }
impl<'a, 'de> serde::de::MapAccess<'de> for MapAccess<'a, 'de> { impl<'de> serde::de::MapAccess<'de> for MapAccess<'_, 'de> {
type Error = Error; type Error = Error;
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error> fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
@ -559,7 +559,7 @@ impl<'a, 'de> serde::de::MapAccess<'de> for MapAccess<'a, 'de> {
} }
} }
impl<'a, 'de> serde::de::SeqAccess<'de> for SeqAccess<'a, 'de> { impl<'de> serde::de::SeqAccess<'de> for SeqAccess<'_, 'de> {
type Error = Error; type Error = Error;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error> fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>

View file

@ -97,7 +97,7 @@ impl<W: std::io::Write> BencodeSerializer<W> {
struct SerializeSeq<'ser, W: std::io::Write> { struct SerializeSeq<'ser, W: std::io::Write> {
ser: &'ser mut BencodeSerializer<W>, ser: &'ser mut BencodeSerializer<W>,
} }
impl<'ser, W: std::io::Write> serde::ser::SerializeSeq for SerializeSeq<'ser, W> { impl<W: std::io::Write> serde::ser::SerializeSeq for SerializeSeq<'_, W> {
type Ok = (); type Ok = ();
type Error = SerError; type Error = SerError;
@ -117,7 +117,7 @@ impl<'ser, W: std::io::Write> serde::ser::SerializeSeq for SerializeSeq<'ser, W>
struct SerializeTuple<'ser, W: std::io::Write> { struct SerializeTuple<'ser, W: std::io::Write> {
ser: &'ser mut BencodeSerializer<W>, ser: &'ser mut BencodeSerializer<W>,
} }
impl<'ser, W: std::io::Write> serde::ser::SerializeTuple for SerializeTuple<'ser, W> { impl<W: std::io::Write> serde::ser::SerializeTuple for SerializeTuple<'_, W> {
type Ok = (); type Ok = ();
type Error = SerError; type Error = SerError;
@ -139,7 +139,7 @@ struct SerializeMap<'ser, W: std::io::Write> {
tmp: BTreeMap<ByteBufOwned, ByteBufOwned>, tmp: BTreeMap<ByteBufOwned, ByteBufOwned>,
last_key: Option<ByteBufOwned>, last_key: Option<ByteBufOwned>,
} }
impl<'ser, W: std::io::Write> serde::ser::SerializeMap for SerializeMap<'ser, W> { impl<W: std::io::Write> serde::ser::SerializeMap for SerializeMap<'_, W> {
type Ok = (); type Ok = ();
type Error = SerError; type Error = SerError;
@ -182,7 +182,7 @@ struct SerializeStruct<'ser, W: std::io::Write> {
ser: &'ser mut BencodeSerializer<W>, ser: &'ser mut BencodeSerializer<W>,
tmp: BTreeMap<&'static str, ByteBufOwned>, tmp: BTreeMap<&'static str, ByteBufOwned>,
} }
impl<'ser, W: std::io::Write> serde::ser::SerializeStruct for SerializeStruct<'ser, W> { impl<W: std::io::Write> serde::ser::SerializeStruct for SerializeStruct<'_, W> {
type Ok = (); type Ok = ();
type Error = SerError; type Error = SerError;

View file

@ -29,14 +29,14 @@ impl ByteBufT for ByteBufOwned {
} }
} }
impl<'a> ByteBufT for ByteBuf<'a> { impl ByteBufT for ByteBuf<'_> {
fn as_slice(&self) -> &[u8] { fn as_slice(&self) -> &[u8] {
self.as_ref() self.as_ref()
} }
} }
struct HexBytes<'a>(&'a [u8]); struct HexBytes<'a>(&'a [u8]);
impl<'a> std::fmt::Display for HexBytes<'a> { impl std::fmt::Display for HexBytes<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for byte in self.0 { for byte in self.0 {
write!(f, "{byte:02x?}")?; write!(f, "{byte:02x?}")?;
@ -71,13 +71,13 @@ fn debug_bytes(b: &[u8], f: &mut std::fmt::Formatter<'_>, debug_strings: bool) -
write!(f, "<{} bytes>", b.len()) write!(f, "<{} bytes>", b.len())
} }
impl<'a> std::fmt::Debug for ByteBuf<'a> { impl std::fmt::Debug for ByteBuf<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
debug_bytes(self.0, f, true) debug_bytes(self.0, f, true)
} }
} }
impl<'a> std::fmt::Display for ByteBuf<'a> { impl std::fmt::Display for ByteBuf<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
debug_bytes(self.0, f, false) debug_bytes(self.0, f, false)
} }
@ -95,7 +95,7 @@ impl std::fmt::Display for ByteBufOwned {
} }
} }
impl<'a> CloneToOwned for ByteBuf<'a> { impl CloneToOwned for ByteBuf<'_> {
type Target = ByteBufOwned; type Target = ByteBufOwned;
fn clone_to_owned(&self, within_buffer: Option<&Bytes>) -> Self::Target { fn clone_to_owned(&self, within_buffer: Option<&Bytes>) -> Self::Target {
@ -126,7 +126,7 @@ impl CloneToOwned for ByteBufOwned {
} }
} }
impl<'a> std::convert::AsRef<[u8]> for ByteBuf<'a> { impl std::convert::AsRef<[u8]> for ByteBuf<'_> {
fn as_ref(&self) -> &[u8] { fn as_ref(&self) -> &[u8] {
self.0 self.0
} }
@ -144,13 +144,13 @@ impl std::borrow::Borrow<[u8]> for ByteBufOwned {
} }
} }
impl<'a> std::borrow::Borrow<[u8]> for ByteBuf<'a> { impl std::borrow::Borrow<[u8]> for ByteBuf<'_> {
fn borrow(&self) -> &[u8] { fn borrow(&self) -> &[u8] {
self.0 self.0
} }
} }
impl<'a> std::ops::Deref for ByteBuf<'a> { impl std::ops::Deref for ByteBuf<'_> {
type Target = [u8]; type Target = [u8];
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -190,7 +190,7 @@ impl From<Bytes> for ByteBufOwned {
} }
} }
impl<'a> serde::ser::Serialize for ByteBuf<'a> { impl serde::ser::Serialize for ByteBuf<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
S: serde::Serializer, S: serde::Serializer,
@ -215,7 +215,7 @@ impl<'de> serde::de::Deserialize<'de> for ByteBufOwned {
{ {
struct Visitor; struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor { impl serde::de::Visitor<'_> for Visitor {
type Value = ByteBufOwned; type Value = ByteBufOwned;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View file

@ -27,7 +27,7 @@ impl<'de> Deserialize<'de> for MessageType {
D: serde::Deserializer<'de>, D: serde::Deserializer<'de>,
{ {
struct Visitor; struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor { impl serde::de::Visitor<'_> for Visitor {
type Value = MessageType; type Value = MessageType;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
@ -271,7 +271,7 @@ impl<'de> Deserialize<'de> for CompactPeerInfo {
D: Deserializer<'de>, D: Deserializer<'de>,
{ {
struct Visitor; struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor { impl serde::de::Visitor<'_> for Visitor {
type Value = CompactPeerInfo; type Value = CompactPeerInfo;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View file

@ -51,7 +51,7 @@ impl Serialize for PeerStore {
peers: &'a dashmap::DashMap<Id20, Vec<StoredPeer>>, peers: &'a dashmap::DashMap<Id20, Vec<StoredPeer>>,
} }
impl<'a> Serialize for SerializePeers<'a> { impl Serialize for SerializePeers<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
S: serde::Serializer, S: serde::Serializer,

View file

@ -83,7 +83,7 @@ pub struct BucketTreeIteratorItem<'a> {
pub leaf: &'a LeafBucket, pub leaf: &'a LeafBucket,
} }
impl<'a> BucketTreeIteratorItem<'a> { impl BucketTreeIteratorItem<'_> {
pub fn random_within(&self) -> Id20 { pub fn random_within(&self) -> Id20 {
generate_random_id(self.start, self.bits) generate_random_id(self.start, self.bits)
} }

View file

@ -85,7 +85,7 @@ impl<'a> FileOps<'a> {
processed_bytes: u64, processed_bytes: u64,
is_broken: bool, is_broken: bool,
} }
impl<'a> CurrentFile<'a> { impl CurrentFile<'_> {
fn remaining(&self) -> u64 { fn remaining(&self) -> u64 {
self.fi.len - self.processed_bytes self.fi.len - self.processed_bytes
} }

View file

@ -23,7 +23,7 @@ impl Subscriber {
} }
} }
impl<'a> MakeWriter<'a> for Subscriber { impl MakeWriter<'_> for Subscriber {
type Writer = LineWriter<Writer>; type Writer = LineWriter<Writer>;
fn make_writer(&self) -> Self::Writer { fn make_writer(&self) -> Self::Writer {

View file

@ -125,7 +125,7 @@ pub enum FileIteratorName<'a, BufType> {
Tree(&'a [BufType]), Tree(&'a [BufType]),
} }
impl<'a, BufType> std::fmt::Debug for FileIteratorName<'a, BufType> impl<BufType> std::fmt::Debug for FileIteratorName<'_, BufType>
where where
BufType: AsRef<[u8]>, BufType: AsRef<[u8]>,
{ {
@ -203,7 +203,7 @@ pub struct FileDetails<'a, BufType> {
pub symlink_path: Option<&'a [BufType]>, pub symlink_path: Option<&'a [BufType]>,
} }
impl<'a, BufType> FileDetails<'a, BufType> impl<BufType> FileDetails<'_, BufType>
where where
BufType: AsRef<[u8]>, BufType: AsRef<[u8]>,
{ {
@ -235,7 +235,7 @@ pub struct FileDetailsExt<'a, BufType> {
pub pieces: std::ops::Range<u32>, pub pieces: std::ops::Range<u32>,
} }
impl<'a, BufType> FileDetailsExt<'a, BufType> { impl<BufType> FileDetailsExt<'_, BufType> {
pub fn pieces_usize(&self) -> std::ops::Range<usize> { pub fn pieces_usize(&self) -> std::ops::Range<usize> {
self.pieces.start as usize..self.pieces.end as usize self.pieces.start as usize..self.pieces.end as usize
} }

View file

@ -47,11 +47,11 @@ impl ExtendedHandshake<ByteBuf<'static>> {
} }
} }
impl<'a, ByteBuf> ExtendedHandshake<ByteBuf> impl<ByteBuf> ExtendedHandshake<ByteBuf>
where where
ByteBuf: ByteBufT, ByteBuf: ByteBufT,
{ {
fn get_msgid(&self, msg_type: &'a [u8]) -> Option<u8> { fn get_msgid(&self, msg_type: &[u8]) -> Option<u8> {
self.m.get(msg_type).copied() self.m.get(msg_type).copied()
} }

View file

@ -105,7 +105,7 @@ where
struct Visitor<T> { struct Visitor<T> {
p: PhantomData<T>, p: PhantomData<T>,
} }
impl<'de, T> serde::de::Visitor<'de> for Visitor<T> impl<T> serde::de::Visitor<'_> for Visitor<T>
where where
T: IpLike, T: IpLike,
{ {

View file

@ -246,7 +246,7 @@ impl<'a> Bitfield<'a> {
} }
} }
impl<'a> std::fmt::Debug for Bitfield<'a> { impl std::fmt::Debug for Bitfield<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Bitfield") f.debug_struct("Bitfield")
.field("_ones", &self.data.count_ones()) .field("_ones", &self.data.count_ones())

View file

@ -52,7 +52,7 @@ pub struct DictPeer<'a> {
port: u16, port: u16,
} }
impl<'a> DictPeer<'a> { impl DictPeer<'_> {
fn as_sockaddr(&self) -> SocketAddr { fn as_sockaddr(&self) -> SocketAddr {
SocketAddr::new(self.ip, self.port) SocketAddr::new(self.ip, self.port)
} }
@ -118,7 +118,7 @@ where
D: Deserializer<'de>, D: Deserializer<'de>,
{ {
struct Visitor; struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor { impl serde::de::Visitor<'_> for Visitor {
type Value = IpAddr; type Value = IpAddr;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View file

@ -39,7 +39,7 @@ pub struct SsdpMSearchRequest<'a> {
pub st: &'a BStr, pub st: &'a BStr,
} }
impl<'a> SsdpMSearchRequest<'a> { impl SsdpMSearchRequest<'_> {
fn matches_media_server(&self) -> bool { fn matches_media_server(&self) -> bool {
if self.man != "\"ssdp:discover\"" { if self.man != "\"ssdp:discover\"" {
return false; return false;
@ -81,7 +81,7 @@ pub fn try_parse_ssdp<'a, 'h>(
match (host, man, st) { match (host, man, st) {
(Some(host), Some(man), Some(st)) => { (Some(host), Some(man), Some(st)) => {
return Ok(SsdpMessage::MSearch(SsdpMSearchRequest { Ok(SsdpMessage::MSearch(SsdpMSearchRequest {
host: BStr::new(host), host: BStr::new(host),
man: BStr::new(man), man: BStr::new(man),
st: BStr::new(st), st: BStr::new(st),
@ -90,7 +90,7 @@ pub fn try_parse_ssdp<'a, 'h>(
_ => bail!("not all of host, man and st are set"), _ => bail!("not all of host, man and st are set"),
} }
} }
_ => return Ok(SsdpMessage::OtherRequest(req)), _ => Ok(SsdpMessage::OtherRequest(req)),
} }
} }