@@ -5,11 +5,6 @@ use std::future::Future;
55use crate :: io:: { self , Write } ;
66use crate :: task:: { spawn_blocking, Context , JoinHandle , Poll } ;
77
8- cfg_unstable ! {
9- use once_cell:: sync:: Lazy ;
10- use std:: io:: Write as _;
11- }
12-
138/// Constructs a new handle to the standard error of the current process.
149///
1510/// This function is an async version of [`std::io::stderr`].
@@ -58,22 +53,6 @@ pub fn stderr() -> Stderr {
5853#[ derive( Debug ) ]
5954pub struct Stderr ( Mutex < State > ) ;
6055
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-
7756/// The state of the asynchronous stderr.
7857///
7958/// The stderr can be either idle or busy performing an asynchronous operation.
@@ -108,35 +87,6 @@ enum Operation {
10887 Flush ( io:: Result < ( ) > ) ,
10988}
11089
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-
14090impl Write for Stderr {
14191 fn poll_write (
14292 mut self : Pin < & mut Self > ,
@@ -239,23 +189,3 @@ cfg_windows! {
239189 }
240190 }
241191}
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