File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ pub fn stdin() -> Stdin {
47
47
#[ derive( Debug ) ]
48
48
pub struct Stdin ( Mutex < State > ) ;
49
49
50
+ #[ derive( Debug ) ]
51
+ pub struct StdinLock < ' a > ( std:: io:: StdinLock < ' a > ) ;
52
+
53
+ unsafe impl Send for StdinLock < ' _ > { }
54
+
50
55
/// The state of the asynchronous stdin.
51
56
///
52
57
/// The stdin can be either idle or busy performing an asynchronous operation.
@@ -157,12 +162,14 @@ impl Stdin {
157
162
/// #
158
163
/// # Ok(()) }) }
159
164
/// ```
160
- pub async fn lock ( & self ) -> std :: io :: StdinLock < ' static > {
165
+ pub async fn lock ( & self ) -> StdinLock < ' static > {
161
166
lazy_static ! {
162
167
static ref STDIN : std:: io:: Stdin = std:: io:: stdin( ) ;
163
168
}
164
169
165
- STDIN . lock ( )
170
+ blocking:: spawn ( async {
171
+ StdinLock ( STDIN . lock ( ) )
172
+ } ) . await
166
173
}
167
174
}
168
175
@@ -248,3 +255,13 @@ cfg_if! {
248
255
}
249
256
}
250
257
}
258
+
259
+ impl Read for StdinLock < ' _ > {
260
+ fn poll_read (
261
+ self : Pin < & mut Self > ,
262
+ _cx : & mut Context < ' _ > ,
263
+ _buf : & mut [ u8 ] ,
264
+ ) -> Poll < io:: Result < usize > > {
265
+ unimplemented ! ( )
266
+ }
267
+ }
You can’t perform that action at this time.
0 commit comments