@@ -5,11 +5,6 @@ use std::future::Future;
5
5
use crate :: io:: { self , Write } ;
6
6
use crate :: task:: { spawn_blocking, Context , JoinHandle , Poll } ;
7
7
8
- cfg_unstable ! {
9
- use once_cell:: sync:: Lazy ;
10
- use std:: io:: Write as _;
11
- }
12
-
13
8
/// Constructs a new handle to the standard error of the current process.
14
9
///
15
10
/// This function is an async version of [`std::io::stderr`].
@@ -58,22 +53,6 @@ pub fn stderr() -> Stderr {
58
53
#[ derive( Debug ) ]
59
54
pub struct Stderr ( Mutex < State > ) ;
60
55
61
- /// A locked reference to the Stderr handle.
62
- ///
63
- /// This handle implements the [`Write`] traits, and is constructed via the [`Stderr::lock`]
64
- /// method.
65
- ///
66
- /// [`Write`]: trait.Read.html
67
- /// [`Stderr::lock`]: struct.Stderr.html#method.lock
68
- #[ cfg( feature = "unstable" ) ]
69
- #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
70
- #[ derive( Debug ) ]
71
- pub struct StderrLock < ' a > ( std:: io:: StderrLock < ' a > ) ;
72
-
73
- #[ cfg( feature = "unstable" ) ]
74
- #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
75
- unsafe impl Send for StderrLock < ' _ > { }
76
-
77
56
/// The state of the asynchronous stderr.
78
57
///
79
58
/// The stderr can be either idle or busy performing an asynchronous operation.
@@ -108,35 +87,6 @@ enum Operation {
108
87
Flush ( io:: Result < ( ) > ) ,
109
88
}
110
89
111
- impl Stderr {
112
- /// Locks this handle to the standard error stream, returning a writable guard.
113
- ///
114
- /// The lock is released when the returned lock goes out of scope. The returned guard also implements the Write trait for writing data.
115
- ///
116
- /// # Examples
117
- ///
118
- /// ```no_run
119
- /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
120
- /// #
121
- /// use async_std::io;
122
- /// use async_std::prelude::*;
123
- ///
124
- /// let stderr = io::stderr();
125
- /// let mut handle = stderr.lock().await;
126
- ///
127
- /// handle.write_all(b"hello world").await?;
128
- /// #
129
- /// # Ok(()) }) }
130
- /// ```
131
- #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
132
- #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
133
- pub async fn lock ( & self ) -> StderrLock < ' static > {
134
- static STDERR : Lazy < std:: io:: Stderr > = Lazy :: new ( std:: io:: stderr) ;
135
-
136
- spawn_blocking ( move || StderrLock ( STDERR . lock ( ) ) ) . await
137
- }
138
- }
139
-
140
90
impl Write for Stderr {
141
91
fn poll_write (
142
92
mut self : Pin < & mut Self > ,
@@ -239,23 +189,3 @@ cfg_windows! {
239
189
}
240
190
}
241
191
}
242
-
243
- #[ cfg( feature = "unstable" ) ]
244
- #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
245
- impl io:: Write for StderrLock < ' _ > {
246
- fn poll_write (
247
- mut self : Pin < & mut Self > ,
248
- _cx : & mut Context < ' _ > ,
249
- buf : & [ u8 ] ,
250
- ) -> Poll < io:: Result < usize > > {
251
- Poll :: Ready ( self . 0 . write ( buf) )
252
- }
253
-
254
- fn poll_flush ( mut self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
255
- Poll :: Ready ( self . 0 . flush ( ) )
256
- }
257
-
258
- fn poll_close ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < ( ) > > {
259
- self . poll_flush ( cx)
260
- }
261
- }
0 commit comments