Skip to content

Commit

Permalink
Fix clippy w/e
Browse files Browse the repository at this point in the history
  • Loading branch information
Stargateur committed Mar 26, 2024
1 parent 5c110fb commit f1eefd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where
(is(b'2'), is(b'5'), to_digit)
.try_map(|(_, _, c)| {
250u8
.checked_add(u8::from(c))
.checked_add(c)
.ok_or_else(|| Context::new(IpAddrAtom::NotAnOctet))
})
.parse(stream)
Expand All @@ -116,7 +116,7 @@ where
(is(b'2'), to_digit, to_digit)
.try_map(|(_, b, c)| {
200u8
.checked_add(u8::from(b) * 10 + u8::from(c))
.checked_add(b * 10 + c)
.ok_or_else(|| Context::new(IpAddrAtom::NotAnOctet))
})
.parse(stream)
Expand All @@ -129,7 +129,7 @@ where
(is(b'1'), to_digit, to_digit)
.try_map(|(_, b, c)| {
100u8
.checked_add(u8::from(b) * 10 + u8::from(c))
.checked_add(b * 10 + c)
.ok_or_else(|| Context::new(IpAddrAtom::NotAnOctet))
})
.parse(stream)
Expand All @@ -141,8 +141,6 @@ where
{
(to_digit, to_digit)
.try_map(|(a, b)| {
let a = u8::from(a);
let b = u8::from(b);
if a == 0 {
Err(Context::new(IpAddrAtom::LeadingZero))
} else {
Expand Down Expand Up @@ -448,7 +446,10 @@ where
.and(colon_h16)
.or(ipv4_address.map(|ipv4| {
let [a, b, c, d] = ipv4.octets();
((a as u16) << 8 | (b as u16), (c as u16) << 8 | (d as u16))
(
(a as u16) << 8u16 | (b as u16),
(c as u16) << 8u16 | (d as u16),
)
}))
.parse(stream)
}
Expand Down
24 changes: 12 additions & 12 deletions src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ macro_rules! tcp_flags {
}

tcp_flags! {
reserved_0 => 11,
reserved_1 => 10,
reserved_2 => 9,
ns => 8,
cwr => 7,
ece => 6,
urg => 5,
ack => 4,
psh => 3,
rst => 2,
syn => 1,
fin => 0,
reserved_0 => 11u16,
reserved_1 => 10u16,
reserved_2 => 9u16,
ns => 8u16,
cwr => 7u16,
ece => 6u16,
urg => 5u16,
ack => 4u16,
psh => 3u16,
rst => 2u16,
syn => 1u16,
fin => 0u16,
}

impl From<u16> for TcpFlags {
Expand Down

0 comments on commit f1eefd2

Please sign in to comment.