File tree Expand file tree Collapse file tree 2 files changed +50
-4
lines changed Expand file tree Collapse file tree 2 files changed +50
-4
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ enum Operation {
7878    Flush ( io:: Result < ( ) > ) , 
7979} 
8080
81+ #[ derive( Debug ) ]  
82+ pub  struct  StderrLock < ' a > ( std:: io:: StderrLock < ' a > ) ; 
83+ 
84+ unsafe  impl  Send  for  StderrLock < ' _ >  { } 
85+ 
8186impl  Stderr  { 
8287    /// Locks this handle to the standard error stream, returning a writable guard. 
8388     /// 
@@ -98,12 +103,12 @@ impl Stderr {
98103     /// # 
99104     /// # Ok(()) }) } 
100105     /// ``` 
101-      pub  async  fn  lock ( & self )  -> std :: io :: StderrLock < ' static >  { 
106+      pub  async  fn  lock ( & self )  -> StderrLock < ' static >  { 
102107        lazy_static !  { 
103108            static  ref STDERR :  std:: io:: Stderr  = std:: io:: stderr( ) ; 
104109        } 
105110
106-         STDERR . lock ( ) 
111+         blocking :: spawn ( move  ||  {   StderrLock ( STDERR . lock ( ) )   } ) . await 
107112    } 
108113} 
109114
@@ -209,3 +214,21 @@ cfg_windows! {
209214        } 
210215    } 
211216} 
217+ 
218+ impl  Write  for  StderrLock < ' _ >  { 
219+     fn  poll_write ( 
220+         self :  Pin < & mut  Self > , 
221+         _cx :  & mut  Context < ' _ > , 
222+         _buf :  & [ u8 ] , 
223+     )  -> Poll < io:: Result < usize > >  { 
224+         unimplemented ! ( ) 
225+     } 
226+ 
227+     fn  poll_flush ( self :  Pin < & mut  Self > ,  _cx :  & mut  Context < ' _ > )  -> Poll < io:: Result < ( ) > >  { 
228+         unimplemented ! ( ) 
229+     } 
230+ 
231+     fn  poll_close ( self :  Pin < & mut  Self > ,  _cx :  & mut  Context < ' _ > )  -> Poll < io:: Result < ( ) > >  { 
232+         unimplemented ! ( ) 
233+     } 
234+ } 
Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ pub fn stdout() -> Stdout {
4444#[ derive( Debug ) ]  
4545pub  struct  Stdout ( Mutex < State > ) ; 
4646
47+ #[ derive( Debug ) ]  
48+ pub  struct  StdoutLock < ' a > ( std:: io:: StdoutLock < ' a > ) ; 
49+ 
50+ unsafe  impl  Send  for  StdoutLock < ' _ >  { } 
51+ 
4752/// The state of the asynchronous stdout. 
4853/// 
4954/// The stdout can be either idle or busy performing an asynchronous operation. 
@@ -98,12 +103,12 @@ impl Stdout {
98103     /// # 
99104     /// # Ok(()) }) } 
100105     /// ``` 
101-      pub  async  fn  lock ( & self )  -> std :: io :: StdoutLock < ' static >  { 
106+      pub  async  fn  lock ( & self )  -> StdoutLock < ' static >  { 
102107        lazy_static !  { 
103108            static  ref STDOUT :  std:: io:: Stdout  = std:: io:: stdout( ) ; 
104109        } 
105110
106-         STDOUT . lock ( ) 
111+         blocking :: spawn ( move  ||  { StdoutLock ( STDOUT . lock ( ) ) } ) . await 
107112    } 
108113} 
109114
@@ -209,3 +214,21 @@ cfg_windows! {
209214        } 
210215    } 
211216} 
217+ 
218+ impl  Write  for  StdoutLock < ' _ >  { 
219+     fn  poll_write ( 
220+         self :  Pin < & mut  Self > , 
221+         _cx :  & mut  Context < ' _ > , 
222+         _buf :  & [ u8 ] , 
223+     )  -> Poll < io:: Result < usize > >  { 
224+         unimplemented ! ( ) 
225+     } 
226+ 
227+     fn  poll_flush ( self :  Pin < & mut  Self > ,  _cx :  & mut  Context < ' _ > )  -> Poll < io:: Result < ( ) > >  { 
228+         unimplemented ! ( ) 
229+     } 
230+ 
231+     fn  poll_close ( self :  Pin < & mut  Self > ,  _cx :  & mut  Context < ' _ > )  -> Poll < io:: Result < ( ) > >  { 
232+         unimplemented ! ( ) 
233+     } 
234+ } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments