@@ -113,7 +113,7 @@ macro_rules! impl_try_from_tokio_process_child_for_stdio {
113
113
type Error = Error ;
114
114
115
115
fn try_from( arg: tokio:: process:: $type) -> Result <Self , Self :: Error > {
116
- let wrapper: $type = arg . try_into ( ) ?;
116
+ let wrapper: $type = TryFromChildIo :: try_from ( arg ) ?;
117
117
Ok ( wrapper. 0 . into( ) )
118
118
}
119
119
}
@@ -136,26 +136,32 @@ pub struct ChildStdout(tokio_pipe::PipeRead);
136
136
#[ derive( Debug ) ]
137
137
pub struct ChildStderr ( tokio_pipe:: PipeRead ) ;
138
138
139
+ pub ( crate ) trait TryFromChildIo < T > : Sized {
140
+ type Error ;
141
+
142
+ fn try_from ( arg : T ) -> Result < Self , Self :: Error > ;
143
+ }
144
+
139
145
macro_rules! impl_from_impl_child_io {
140
146
( process, $type: ident, $inner: ty) => {
141
- impl TryFrom <tokio:: process:: $type> for $type {
147
+ impl TryFromChildIo <tokio:: process:: $type> for $type {
142
148
type Error = Error ;
143
149
144
150
fn try_from( arg: tokio:: process:: $type) -> Result <Self , Self :: Error > {
145
151
let fd = arg. as_raw_fd( ) ;
146
152
147
153
// safety: arg.as_raw_fd() is guaranteed to return a valid fd.
148
154
let fd = unsafe { dup( fd) } ?. into_raw_fd( ) ;
149
- Ok ( Self (
150
- <$inner> :: from_raw_fd_checked ( fd ) . map_err ( Error :: ChildIo ) ? ,
151
- ) )
155
+ <$inner> :: from_raw_fd_checked ( fd )
156
+ . map ( Self )
157
+ . map_err ( Error :: ChildIo )
152
158
}
153
159
}
154
160
} ;
155
161
156
162
( native_mux, $type: ident) => {
157
163
#[ cfg( feature = "native-mux" ) ]
158
- impl TryFrom <native_mux_impl:: $type> for $type {
164
+ impl TryFromChildIo <native_mux_impl:: $type> for $type {
159
165
type Error = Error ;
160
166
161
167
fn try_from( arg: native_mux_impl:: $type) -> Result <Self , Self :: Error > {
0 commit comments