chore: clippy suggestions

This commit is contained in:
zonyitoo
2024-11-28 23:15:46 +08:00
parent 61f6e799fa
commit cf9504abbb
8 changed files with 15 additions and 15 deletions

View File

@@ -70,7 +70,7 @@ impl Socks5UdpClient {
send_buf.put_slice(buf);
let n = self.socket.send(&send_buf).await?;
Ok(if n <= header_len { 0 } else { n - header_len })
Ok(n.saturating_sub(header_len))
}
/// Returns a future that receives a single datagram on the socket. On success, the future resolves to the number of bytes read and the origin.

View File

@@ -129,7 +129,7 @@ impl FromStr for Mode {
struct ModeVisitor;
impl<'de> serde::de::Visitor<'de> for ModeVisitor {
impl serde::de::Visitor<'_> for ModeVisitor {
type Value = Mode;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@@ -1078,7 +1078,7 @@ impl Display for ServerAddr {
struct ServerAddrVisitor;
impl<'de> serde::de::Visitor<'de> for ServerAddrVisitor {
impl serde::de::Visitor<'_> for ServerAddrVisitor {
type Value = ServerAddr;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@@ -1259,7 +1259,7 @@ impl Display for ManagerAddr {
struct ManagerAddrVisitor;
impl<'de> serde::de::Visitor<'de> for ManagerAddrVisitor {
impl serde::de::Visitor<'_> for ManagerAddrVisitor {
type Value = ManagerAddr;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {

View File

@@ -315,7 +315,7 @@ impl DnsResolver {
}
}
impl<'x, 'y> Drop for ResolverLogger<'x, 'y> {
impl Drop for ResolverLogger<'_, '_> {
fn drop(&mut self) {
match self.start_time {
Some(start_time) => {

View File

@@ -86,7 +86,7 @@ pub enum TcpRequestHeaderRef<'a> {
Aead2022(Aead2022TcpRequestHeaderRef<'a>),
}
impl<'a> TcpRequestHeaderRef<'a> {
impl TcpRequestHeaderRef<'_> {
pub fn write_to_buf<B: BufMut>(&self, buf: &mut B) {
match *self {
TcpRequestHeaderRef::Stream(ref h) => h.write_to_buf(buf),

View File

@@ -33,7 +33,7 @@ pub struct StreamTcpRequestHeaderRef<'a> {
pub addr: &'a Address,
}
impl<'a> StreamTcpRequestHeaderRef<'a> {
impl StreamTcpRequestHeaderRef<'_> {
pub fn write_to_buf<B: BufMut>(&self, buf: &mut B) {
self.addr.write_to_buf(buf);
}

View File

@@ -72,7 +72,7 @@ pub struct Aead2022TcpRequestHeaderRef<'a> {
pub padding_size: u16,
}
impl<'a> Aead2022TcpRequestHeaderRef<'a> {
impl Aead2022TcpRequestHeaderRef<'_> {
pub fn write_to_buf<B: BufMut>(&self, buf: &mut B) {
assert!(
self.padding_size as usize <= MAX_PADDING_SIZE,

View File

@@ -240,7 +240,7 @@ where
}
}
impl<'a, A, B> Future for CopyBidirectional<'a, A, B>
impl<A, B> Future for CopyBidirectional<'_, A, B>
where
A: AsyncRead + AsyncWrite + Unpin + ?Sized,
B: AsyncRead + AsyncWrite + Unpin + ?Sized,

View File

@@ -81,7 +81,7 @@ pub struct RecvFut<'a, S: DatagramReceive + ?Sized> {
buf: &'a mut [u8],
}
impl<'a, S: DatagramReceive + ?Sized> Future for RecvFut<'a, S> {
impl<S: DatagramReceive + ?Sized> Future for RecvFut<'_, S> {
type Output = io::Result<usize>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -101,7 +101,7 @@ pub struct RecvFromFut<'a, S: DatagramReceive + ?Sized> {
buf: &'a mut [u8],
}
impl<'a, S: DatagramReceive + ?Sized> Future for RecvFromFut<'a, S> {
impl<S: DatagramReceive + ?Sized> Future for RecvFromFut<'_, S> {
type Output = io::Result<(usize, SocketAddr)>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -118,7 +118,7 @@ pub struct RecvReadyFut<'a, S: DatagramReceive + ?Sized> {
io: &'a S,
}
impl<'a, S: DatagramReceive + ?Sized> Future for RecvReadyFut<'a, S> {
impl<S: DatagramReceive + ?Sized> Future for RecvReadyFut<'_, S> {
type Output = io::Result<()>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -132,7 +132,7 @@ pub struct SendFut<'a, S: DatagramSend + ?Sized> {
buf: &'a [u8],
}
impl<'a, S: DatagramSend + ?Sized> Future for SendFut<'a, S> {
impl<S: DatagramSend + ?Sized> Future for SendFut<'_, S> {
type Output = io::Result<usize>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -147,7 +147,7 @@ pub struct SendToFut<'a, S: DatagramSend + ?Sized> {
buf: &'a [u8],
}
impl<'a, S: DatagramSend + ?Sized> Future for SendToFut<'a, S> {
impl<S: DatagramSend + ?Sized> Future for SendToFut<'_, S> {
type Output = io::Result<usize>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -160,7 +160,7 @@ pub struct SendReadyFut<'a, S: DatagramSend + ?Sized> {
io: &'a S,
}
impl<'a, S: DatagramSend + ?Sized> Future for SendReadyFut<'a, S> {
impl<S: DatagramSend + ?Sized> Future for SendReadyFut<'_, S> {
type Output = io::Result<()>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {