Dario Nieuwenhuis 2 лет назад
Родитель
Сommit
5db57bcac5
4 измененных файлов с 3 добавлено и 5 удалено
  1. 0 2
      src/socket/dhcpv4.rs
  2. 1 1
      src/socket/tcp.rs
  3. 1 1
      src/socket/udp.rs
  4. 1 1
      src/time.rs

+ 0 - 2
src/socket/dhcpv4.rs

@@ -635,8 +635,6 @@ mod test {
     macro_rules! send {
         ($socket:ident, $repr:expr) =>
             (send!($socket, time 0, $repr));
-        ($socket:ident, $repr:expr, $result:expr) =>
-            (send!($socket, time 0, $repr, $result));
         ($socket:ident, time $time:expr, $repr:expr) =>
             (send!($socket, time $time, $repr, Ok(( ))));
         ($socket:ident, time $time:expr, $repr:expr, $result:expr) =>

+ 1 - 1
src/socket/tcp.rs

@@ -106,7 +106,7 @@ impl RttEstimator {
     fn sample(&mut self, new_rtt: u32) {
         // "Congestion Avoidance and Control", Van Jacobson, Michael J. Karels, 1988
         self.rtt = (self.rtt * 7 + new_rtt + 7) / 8;
-        let diff = (self.rtt as i32 - new_rtt as i32).abs() as u32;
+        let diff = (self.rtt as i32 - new_rtt as i32).unsigned_abs();
         self.deviation = (self.deviation * 3 + diff + 3) / 4;
 
         self.rto_count = 0;

+ 1 - 1
src/socket/udp.rs

@@ -300,7 +300,7 @@ impl<'a> UdpSocket<'a> {
         if self.endpoint.port != repr.dst_port {
             return false;
         }
-        if !self.endpoint.addr.is_none()
+        if self.endpoint.addr.is_some()
             && self.endpoint.addr != Some(ip_repr.dst_addr())
             && !ip_repr.dst_addr().is_broadcast()
             && !ip_repr.dst_addr().is_multicast()

+ 1 - 1
src/time.rs

@@ -164,7 +164,7 @@ impl ops::Sub<Instant> for Instant {
     type Output = Duration;
 
     fn sub(self, rhs: Instant) -> Duration {
-        Duration::from_micros((self.micros - rhs.micros).abs() as u64)
+        Duration::from_micros((self.micros - rhs.micros).unsigned_abs())
     }
 }