Skip to content

Commit 4d76786

Browse files
committed
Mark From<tokio_pipe::Pipe{Read, Write} for Stdio as deprecated
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 908141c commit 4d76786

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/stdio.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,27 @@ macro_rules! impl_from_for_stdio {
108108
}
109109
}
110110
};
111+
(deprecated $type:ty) => {
112+
#[allow(useless_deprecated)]
113+
#[deprecated(
114+
since = "0.9.8",
115+
note = "Use From<OwnedFd> for Stdio or Stdio::from_raw_fd_owned instead"
116+
)]
117+
/// deprecated, use `From<OwnedFd> for Stdio` or
118+
/// [`Stdio::from_raw_fd_owned`] instead.
119+
impl From<$type> for Stdio {
120+
fn from(arg: $type) -> Self {
121+
let fd = arg.into_raw_fd();
122+
// safety: $type must have a valid into_raw_fd implementation
123+
// and must not be RawFd.
124+
Self(StdioImpl::Fd(unsafe { OwnedFd::from_raw_fd(fd) }, true))
125+
}
126+
}
127+
};
111128
}
112129

113-
impl_from_for_stdio!(tokio_pipe::PipeWrite);
114-
impl_from_for_stdio!(tokio_pipe::PipeRead);
130+
impl_from_for_stdio!(deprecated tokio_pipe::PipeWrite);
131+
impl_from_for_stdio!(deprecated tokio_pipe::PipeRead);
115132

116133
impl_from_for_stdio!(process::ChildStdin);
117134
impl_from_for_stdio!(process::ChildStdout);

0 commit comments

Comments
 (0)