@@ -631,7 +631,7 @@ pub(crate) fn poll_connect(socket: &crate::Socket, timeout: Duration) -> io::Res
631
631
}
632
632
633
633
let timeout = ( timeout - elapsed) . as_millis ( ) ;
634
- let timeout = clamp ( timeout , 1 , c_int:: MAX as u128 ) as c_int ;
634
+ let timeout = timeout . clamp ( 1 , c_int:: MAX as u128 ) as c_int ;
635
635
636
636
match syscall ! ( poll( & mut pollfd, 1 , timeout) ) {
637
637
Ok ( 0 ) => return Err ( io:: ErrorKind :: TimedOut . into ( ) ) ,
@@ -657,20 +657,6 @@ pub(crate) fn poll_connect(socket: &crate::Socket, timeout: Duration) -> io::Res
657
657
}
658
658
}
659
659
660
- // TODO: use clamp from std lib, stable since 1.50.
661
- fn clamp < T > ( value : T , min : T , max : T ) -> T
662
- where
663
- T : Ord ,
664
- {
665
- if value <= min {
666
- min
667
- } else if value >= max {
668
- max
669
- } else {
670
- value
671
- }
672
- }
673
-
674
660
pub ( crate ) fn listen ( fd : Socket , backlog : c_int ) -> io:: Result < ( ) > {
675
661
syscall ! ( listen( fd, backlog) ) . map ( |_| ( ) )
676
662
}
@@ -781,6 +767,7 @@ pub(crate) fn recv_from_vectored(
781
767
782
768
/// Returns the (bytes received, sending address len, `RecvFlags`).
783
769
#[ cfg( not( target_os = "redox" ) ) ]
770
+ #[ allow( clippy:: unnecessary_cast) ] // For `IovLen::MAX as usize` (Already `usize` on Linux).
784
771
fn recvmsg (
785
772
fd : Socket ,
786
773
msg_name : * mut sockaddr_storage ,
@@ -841,6 +828,7 @@ pub(crate) fn send_to_vectored(
841
828
842
829
/// Returns the (bytes received, sending address len, `RecvFlags`).
843
830
#[ cfg( not( target_os = "redox" ) ) ]
831
+ #[ allow( clippy:: unnecessary_cast) ] // For `IovLen::MAX as usize` (Already `usize` on Linux).
844
832
fn sendmsg (
845
833
fd : Socket ,
846
834
msg_name : * const sockaddr_storage ,
0 commit comments