@@ -16,32 +16,38 @@ fn with_std_fd<F: FnOnce(&FileDesc) -> R, R>(fd: abi::Fd, f: F) -> R {
1616
1717impl Stdin {
1818 pub fn new ( ) -> io:: Result < Stdin > { Ok ( Stdin ( ( ) ) ) }
19+ }
1920
20- pub fn read ( & self , data : & mut [ u8 ] ) -> io:: Result < usize > {
21- with_std_fd ( abi:: FD_STDIN , |fd| fd. read ( data) )
21+ impl io:: Read for Stdin {
22+ fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
23+ with_std_fd ( abi:: FD_STDIN , |fd| fd. read ( buf) )
2224 }
2325}
2426
2527impl Stdout {
2628 pub fn new ( ) -> io:: Result < Stdout > { Ok ( Stdout ( ( ) ) ) }
29+ }
2730
28- pub fn write ( & self , data : & [ u8 ] ) -> io:: Result < usize > {
29- with_std_fd ( abi:: FD_STDOUT , |fd| fd. write ( data) )
31+ impl io:: Write for Stdout {
32+ fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
33+ with_std_fd ( abi:: FD_STDOUT , |fd| fd. write ( buf) )
3034 }
3135
32- pub fn flush ( & self ) -> io:: Result < ( ) > {
36+ fn flush ( & mut self ) -> io:: Result < ( ) > {
3337 with_std_fd ( abi:: FD_STDOUT , |fd| fd. flush ( ) )
3438 }
3539}
3640
3741impl Stderr {
3842 pub fn new ( ) -> io:: Result < Stderr > { Ok ( Stderr ( ( ) ) ) }
43+ }
3944
40- pub fn write ( & self , data : & [ u8 ] ) -> io:: Result < usize > {
41- with_std_fd ( abi:: FD_STDERR , |fd| fd. write ( data) )
45+ impl io:: Write for Stderr {
46+ fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
47+ with_std_fd ( abi:: FD_STDERR , |fd| fd. write ( buf) )
4248 }
4349
44- pub fn flush ( & self ) -> io:: Result < ( ) > {
50+ fn flush ( & mut self ) -> io:: Result < ( ) > {
4551 with_std_fd ( abi:: FD_STDERR , |fd| fd. flush ( ) )
4652 }
4753}
0 commit comments