@@ -16,32 +16,38 @@ fn with_std_fd<F: FnOnce(&FileDesc) -> R, R>(fd: abi::Fd, f: F) -> R {
16
16
17
17
impl Stdin {
18
18
pub fn new ( ) -> io:: Result < Stdin > { Ok ( Stdin ( ( ) ) ) }
19
+ }
19
20
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) )
22
24
}
23
25
}
24
26
25
27
impl Stdout {
26
28
pub fn new ( ) -> io:: Result < Stdout > { Ok ( Stdout ( ( ) ) ) }
29
+ }
27
30
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) )
30
34
}
31
35
32
- pub fn flush ( & self ) -> io:: Result < ( ) > {
36
+ fn flush ( & mut self ) -> io:: Result < ( ) > {
33
37
with_std_fd ( abi:: FD_STDOUT , |fd| fd. flush ( ) )
34
38
}
35
39
}
36
40
37
41
impl Stderr {
38
42
pub fn new ( ) -> io:: Result < Stderr > { Ok ( Stderr ( ( ) ) ) }
43
+ }
39
44
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) )
42
48
}
43
49
44
- pub fn flush ( & self ) -> io:: Result < ( ) > {
50
+ fn flush ( & mut self ) -> io:: Result < ( ) > {
45
51
with_std_fd ( abi:: FD_STDERR , |fd| fd. flush ( ) )
46
52
}
47
53
}
0 commit comments