Skip to content

Commit

Permalink
Make clippy happy again
Browse files Browse the repository at this point in the history
  • Loading branch information
theli-ua committed Jun 24, 2021
1 parent 6206d6a commit f0211d7
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/dhcp/clientv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ fn send_packet<DeviceT: for<'d> Device<'d>>(iface: &mut Interface<DeviceT>, raw_
assert!(dhcp_repr.buffer_len() <= dhcp_payload_buf.len());
let dhcp_payload = &mut dhcp_payload_buf[0..dhcp_repr.buffer_len()];
{
let mut dhcp_packet = DhcpPacket::new_checked(&mut dhcp_payload[..])?;
let mut dhcp_packet = DhcpPacket::new_checked(&mut *dhcp_payload)?;
dhcp_repr.emit(&mut dhcp_packet)?;
}

Expand Down
2 changes: 1 addition & 1 deletion src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl FromStr for IpEndpoint {
type Err = ();

fn from_str(s: &str) -> Result<IpEndpoint> {
Parser::new(s).until_eof(|p| Ok(p.accept_ip_endpoint()?))
Parser::new(s).until_eof(|p| p.accept_ip_endpoint())
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/socket/icmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ impl<'a> IcmpSocket<'a> {
}
}

impl<'a> Into<Socket<'a>> for IcmpSocket<'a> {
fn into(self) -> Socket<'a> {
Socket::Icmp(self)
impl<'a> From<IcmpSocket<'a>> for Socket<'a> {
fn from(val: IcmpSocket<'a>) -> Self {
Socket::Icmp(val)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/socket/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ impl<'a> RawSocket<'a> {
}
}

impl<'a> Into<Socket<'a>> for RawSocket<'a> {
fn into(self) -> Socket<'a> {
Socket::Raw(self)
impl<'a> From<RawSocket<'a>> for Socket<'a> {
fn from(val: RawSocket<'a>) -> Self {
Socket::Raw(val)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1985,9 +1985,9 @@ impl<'a> TcpSocket<'a> {
}
}

impl<'a> Into<Socket<'a>> for TcpSocket<'a> {
fn into(self) -> Socket<'a> {
Socket::Tcp(self)
impl<'a> From<TcpSocket<'a>> for Socket<'a> {
fn from(val: TcpSocket<'a>) -> Self {
Socket::Tcp(val)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/socket/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ impl<'a> UdpSocket<'a> {
}
}

impl<'a> Into<Socket<'a>> for UdpSocket<'a> {
fn into(self) -> Socket<'a> {
Socket::Udp(self)
impl<'a> From<UdpSocket<'a>> for Socket<'a> {
fn from(val: UdpSocket<'a>) -> Self {
Socket::Udp(val)
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ impl From<::std::time::SystemTime> for Instant {
}

#[cfg(feature = "std")]
impl Into<::std::time::SystemTime> for Instant {
fn into(self) -> ::std::time::SystemTime {
::std::time::UNIX_EPOCH + ::std::time::Duration::from_millis(self.millis as u64)
impl From<Instant> for ::std::time::SystemTime {
fn from(val: Instant) -> Self {
::std::time::UNIX_EPOCH + ::std::time::Duration::from_millis(val.millis as u64)
}
}

Expand Down Expand Up @@ -238,10 +238,10 @@ impl From<::core::time::Duration> for Duration {
}
}

impl Into<::core::time::Duration> for Duration {
fn into(self) -> ::core::time::Duration {
impl From<Duration> for ::core::time::Duration {
fn from(val: Duration) -> Self {
::core::time::Duration::from_millis(
self.total_millis()
val.total_millis()
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wire/icmpv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl<'a> Repr<'a> {
let mut ip_packet = Ipv4Packet::new_unchecked(packet.data_mut());
header.emit(&mut ip_packet, checksum_caps);
let payload = &mut ip_packet.into_inner()[header.buffer_len()..];
payload.copy_from_slice(&data[..])
payload.copy_from_slice(data)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/wire/icmpv6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ impl<'a> Repr<'a> {
let mut ip_packet = Ipv6Packet::new_unchecked(buffer);
header.emit(&mut ip_packet);
let payload = &mut ip_packet.into_inner()[header.buffer_len()..];
payload.copy_from_slice(&data[..]);
payload.copy_from_slice(data);
}

match *self {
Expand Down
6 changes: 4 additions & 2 deletions src/wire/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl Address {
}

/// Return an unspecified address that has the same IP version as `self`.
#[allow(clippy::wrong_self_convention)]
pub fn to_unspecified(&self) -> Address {
match *self {
Address::Unspecified => Address::Unspecified,
Expand All @@ -179,6 +180,7 @@ impl Address {

/// If `self` is a CIDR-compatible subnet mask, return `Some(prefix_len)`,
/// where `prefix_len` is the number of leading zeroes. Return `None` otherwise.
#[allow(clippy::wrong_self_convention)]
pub fn to_prefix_len(&self) -> Option<u8> {
let mut ones = true;
let mut prefix_len = 0;
Expand Down Expand Up @@ -408,7 +410,7 @@ impl From<::std::net::SocketAddr> for Endpoint {
impl From<::std::net::SocketAddrV4> for Endpoint {
fn from(x: ::std::net::SocketAddrV4) -> Endpoint {
Endpoint {
addr: x.ip().clone().into(),
addr: (*x.ip()).into(),
port: x.port(),
}
}
Expand All @@ -418,7 +420,7 @@ impl From<::std::net::SocketAddrV4> for Endpoint {
impl From<::std::net::SocketAddrV6> for Endpoint {
fn from(x: ::std::net::SocketAddrV6) -> Endpoint {
Endpoint {
addr: x.ip().clone().into(),
addr: (*x.ip()).into(),
port: x.port(),
}
}
Expand Down

0 comments on commit f0211d7

Please sign in to comment.