1
1
use crate :: io;
2
2
use crate :: sys:: anonymous_pipe:: { AnonPipe , pipe as pipe_inner} ;
3
+ use crate :: sys_common:: { FromInner , IntoInner } ;
3
4
4
5
/// Create an anonymous pipe.
5
6
///
@@ -40,7 +41,6 @@ use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner};
40
41
/// # Examples
41
42
///
42
43
/// ```no_run
43
- /// #![feature(anonymous_pipe)]
44
44
/// # #[cfg(miri)] fn main() {}
45
45
/// # #[cfg(not(miri))]
46
46
/// # fn main() -> std::io::Result<()> {
@@ -67,29 +67,52 @@ use crate::sys::anonymous_pipe::{AnonPipe, pipe as pipe_inner};
67
67
/// ```
68
68
/// [changes]: io#platform-specific-behavior
69
69
/// [man page]: https://man7.org/linux/man-pages/man7/pipe.7.html
70
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
70
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
71
71
#[ inline]
72
72
pub fn pipe ( ) -> io:: Result < ( PipeReader , PipeWriter ) > {
73
73
pipe_inner ( ) . map ( |( reader, writer) | ( PipeReader ( reader) , PipeWriter ( writer) ) )
74
74
}
75
75
76
76
/// Read end of an anonymous pipe.
77
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
77
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
78
78
#[ derive( Debug ) ]
79
79
pub struct PipeReader ( pub ( crate ) AnonPipe ) ;
80
80
81
81
/// Write end of an anonymous pipe.
82
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
82
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
83
83
#[ derive( Debug ) ]
84
84
pub struct PipeWriter ( pub ( crate ) AnonPipe ) ;
85
85
86
+ impl FromInner < AnonPipe > for PipeReader {
87
+ fn from_inner ( inner : AnonPipe ) -> Self {
88
+ Self ( inner)
89
+ }
90
+ }
91
+
92
+ impl IntoInner < AnonPipe > for PipeReader {
93
+ fn into_inner ( self ) -> AnonPipe {
94
+ self . 0
95
+ }
96
+ }
97
+
98
+ impl FromInner < AnonPipe > for PipeWriter {
99
+ fn from_inner ( inner : AnonPipe ) -> Self {
100
+ Self ( inner)
101
+ }
102
+ }
103
+
104
+ impl IntoInner < AnonPipe > for PipeWriter {
105
+ fn into_inner ( self ) -> AnonPipe {
106
+ self . 0
107
+ }
108
+ }
109
+
86
110
impl PipeReader {
87
111
/// Create a new [`PipeReader`] instance that shares the same underlying file description.
88
112
///
89
113
/// # Examples
90
114
///
91
115
/// ```no_run
92
- /// #![feature(anonymous_pipe)]
93
116
/// # #[cfg(miri)] fn main() {}
94
117
/// # #[cfg(not(miri))]
95
118
/// # fn main() -> std::io::Result<()> {
@@ -137,7 +160,7 @@ impl PipeReader {
137
160
/// # Ok(())
138
161
/// # }
139
162
/// ```
140
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
163
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
141
164
pub fn try_clone ( & self ) -> io:: Result < Self > {
142
165
self . 0 . try_clone ( ) . map ( Self )
143
166
}
@@ -149,7 +172,6 @@ impl PipeWriter {
149
172
/// # Examples
150
173
///
151
174
/// ```no_run
152
- /// #![feature(anonymous_pipe)]
153
175
/// # #[cfg(miri)] fn main() {}
154
176
/// # #[cfg(not(miri))]
155
177
/// # fn main() -> std::io::Result<()> {
@@ -177,13 +199,13 @@ impl PipeWriter {
177
199
/// # Ok(())
178
200
/// # }
179
201
/// ```
180
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
202
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
181
203
pub fn try_clone ( & self ) -> io:: Result < Self > {
182
204
self . 0 . try_clone ( ) . map ( Self )
183
205
}
184
206
}
185
207
186
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
208
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
187
209
impl io:: Read for & PipeReader {
188
210
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
189
211
self . 0 . read ( buf)
@@ -203,7 +225,7 @@ impl io::Read for &PipeReader {
203
225
}
204
226
}
205
227
206
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
228
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
207
229
impl io:: Read for PipeReader {
208
230
fn read ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
209
231
self . 0 . read ( buf)
@@ -223,7 +245,7 @@ impl io::Read for PipeReader {
223
245
}
224
246
}
225
247
226
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
248
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
227
249
impl io:: Write for & PipeWriter {
228
250
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
229
251
self . 0 . write ( buf)
@@ -241,7 +263,7 @@ impl io::Write for &PipeWriter {
241
263
}
242
264
}
243
265
244
- #[ unstable ( feature = "anonymous_pipe" , issue = "127154 " ) ]
266
+ #[ stable ( feature = "anonymous_pipe" , since = "CURRENT_RUSTC_VERSION " ) ]
245
267
impl io:: Write for PipeWriter {
246
268
fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
247
269
self . 0 . write ( buf)
0 commit comments