File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -42,29 +42,29 @@ impl<W: Write> WriteOutput<W> {
4242}
4343
4444pub struct StringOutput {
45- buf : Vec < u8 > ,
45+ buf : String ,
4646}
4747
4848impl Output for StringOutput {
4949 fn write ( & mut self , seg : & str ) -> Result < ( ) , IOError > {
50- self . buf . extend_from_slice ( seg. as_bytes ( ) ) ;
50+ self . buf . push_str ( seg) ;
5151 Ok ( ( ) )
5252 }
5353
5454 fn write_fmt ( & mut self , args : std:: fmt:: Arguments < ' _ > ) -> Result < ( ) , IOError > {
55- self . buf . write_fmt ( args )
55+ std :: fmt :: Write :: write_fmt ( & mut self . buf , args ) . map_err ( IOError :: other )
5656 }
5757}
5858
5959impl StringOutput {
6060 pub fn new ( ) -> StringOutput {
6161 StringOutput {
62- buf : Vec :: with_capacity ( 8 * 1024 ) ,
62+ buf : String :: with_capacity ( 8 * 1024 ) ,
6363 }
6464 }
6565
6666 pub fn into_string ( self ) -> Result < String , FromUtf8Error > {
67- String :: from_utf8 ( self . buf )
67+ Ok ( self . buf )
6868 }
6969}
7070
You can’t perform that action at this time.
0 commit comments