File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -103,24 +103,22 @@ impl TcpStream {
103103 self . inner . inner . read ( buf)
104104 }
105105
106- pub fn read_vectored ( & self , buf : & mut [ IoVecMut < ' _ > ] ) -> io:: Result < usize > {
107- let buf = match buf. get_mut ( 0 ) {
108- Some ( buf) => buf,
109- None => return Ok ( 0 ) ,
110- } ;
111- self . read ( buf)
106+ pub fn read_vectored ( & self , bufs : & mut [ IoVecMut < ' _ > ] ) -> io:: Result < usize > {
107+ match bufs. iter_mut ( ) . find ( |b| !b. is_empty ( ) ) {
108+ Some ( buf) => self . read ( buf) ,
109+ None => Ok ( 0 ) ,
110+ }
112111 }
113112
114113 pub fn write ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
115114 self . inner . inner . write ( buf)
116115 }
117116
118- pub fn write_vectored ( & self , buf : & [ IoVec < ' _ > ] ) -> io:: Result < usize > {
119- let buf = match buf. get ( 0 ) {
120- Some ( buf) => buf,
121- None => return Ok ( 0 ) ,
122- } ;
123- self . write ( buf)
117+ pub fn write_vectored ( & self , bufs : & [ IoVec < ' _ > ] ) -> io:: Result < usize > {
118+ match bufs. iter ( ) . find ( |b| !b. is_empty ( ) ) {
119+ Some ( buf) => self . write ( buf) ,
120+ None => Ok ( 0 ) ,
121+ }
124122 }
125123
126124 pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
You can’t perform that action at this time.
0 commit comments