File tree 1 file changed +10
-12
lines changed
1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -103,24 +103,22 @@ impl TcpStream {
103
103
self . inner . inner . read ( buf)
104
104
}
105
105
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
+ }
112
111
}
113
112
114
113
pub fn write ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
115
114
self . inner . inner . write ( buf)
116
115
}
117
116
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
+ }
124
122
}
125
123
126
124
pub fn peer_addr ( & self ) -> io:: Result < SocketAddr > {
You can’t perform that action at this time.
0 commit comments