File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1- use std:: io:: { Result , Write } ;
1+ use std:: io:: { IoSlice , Result , Write } ;
22
33/// An adapter around a `Write` stream that guarantees that its output
44/// is valid UTF-8 and contains no control characters. It does this by
@@ -124,6 +124,27 @@ where
124124 return Ok ( result) ;
125125 }
126126
127+ fn write_vectored ( & mut self , bufs : & [ IoSlice ] ) -> Result < usize > {
128+ // Terminal output is [not expected to be atomic], so just write all the
129+ // individual buffers in sequence.
130+ //
131+ // [not expected to be atomic]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html#tag_16_474_08
132+ let mut total_written = 0 ;
133+
134+ for buf in bufs {
135+ let written = self . write ( buf) ?;
136+
137+ total_written += written;
138+
139+ // Stop at the first point where the OS writes less than we asked.
140+ if written < buf. len ( ) {
141+ break ;
142+ }
143+ }
144+
145+ Ok ( total_written)
146+ }
147+
127148 fn flush ( & mut self ) -> Result < ( ) > {
128149 self . inner . flush ( )
129150 }
You can’t perform that action at this time.
0 commit comments