@@ -13,7 +13,7 @@ use crate::panic::{RefUnwindSafe, UnwindSafe};
13
13
#[ cfg( not( target_os = "solana" ) ) ]
14
14
use crate :: io:: { self , BorrowedCursor , BufReader , IoSlice , IoSliceMut , LineWriter , Lines , SpecReadByte } ;
15
15
#[ cfg( target_os = "solana" ) ]
16
- use crate :: io:: { self , BufReader , IoSlice , IoSliceMut } ;
16
+ use crate :: io:: { self , BufReader , IoSlice , IoSliceMut , LineWriter , Lines } ;
17
17
#[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
18
18
use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
19
19
#[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
@@ -357,49 +357,6 @@ pub fn stdin() -> Stdin {
357
357
Stdin { }
358
358
}
359
359
360
- /// Constructs a new locked handle to the standard input of the current
361
- /// process.
362
- ///
363
- /// Each handle returned is a guard granting locked access to a shared
364
- /// global buffer whose access is synchronized via a mutex. If you need
365
- /// more explicit control over locking, for example, in a multi-threaded
366
- /// program, use the [`io::stdin`] function to obtain an unlocked handle,
367
- /// along with the [`Stdin::lock`] method.
368
- ///
369
- /// The lock is released when the returned guard goes out of scope. The
370
- /// returned guard also implements the [`Read`] and [`BufRead`] traits for
371
- /// accessing the underlying data.
372
- ///
373
- /// **Note**: The mutex locked by this handle is not reentrant. Even in a
374
- /// single-threaded program, calling other code that accesses [`Stdin`]
375
- /// could cause a deadlock or panic, if this locked handle is held across
376
- /// that call.
377
- ///
378
- /// ### Note: Windows Portability Consideration
379
- /// When operating in a console, the Windows implementation of this stream does not support
380
- /// non-UTF-8 byte sequences. Attempting to read bytes that are not valid UTF-8 will return
381
- /// an error.
382
- ///
383
- /// # Examples
384
- ///
385
- /// ```no_run
386
- /// #![feature(stdio_locked)]
387
- /// use std::io::{self, BufRead};
388
- ///
389
- /// fn main() -> io::Result<()> {
390
- /// let mut buffer = String::new();
391
- /// let mut handle = io::stdin_locked();
392
- ///
393
- /// handle.read_line(&mut buffer)?;
394
- /// Ok(())
395
- /// }
396
- /// ```
397
- #[ unstable( feature = "stdio_locked" , issue = "86845" ) ]
398
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
399
- pub fn stdin_locked ( ) -> StdinLock < ' static > {
400
- stdin ( ) . into_locked ( )
401
- }
402
-
403
360
impl Stdin {
404
361
/// Locks this handle to the standard input stream, returning a readable
405
362
/// guard.
@@ -423,7 +380,7 @@ impl Stdin {
423
380
/// }
424
381
/// ```
425
382
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
426
- #[ cfg( not( target_os = "solana" ) ) ]
383
+ #[ cfg( not( any ( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
427
384
pub fn lock ( & self ) -> StdinLock < ' static > {
428
385
// Locks this handle with 'static lifetime. This depends on the
429
386
// implementation detail that the underlying `Mutex` is static.
@@ -468,45 +425,6 @@ impl Stdin {
468
425
self . lock ( ) . read_line ( buf)
469
426
}
470
427
471
- // Locks this handle with any lifetime. This depends on the
472
- // implementation detail that the underlying `Mutex` is static.
473
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
474
- fn lock_any < ' a > ( & self ) -> StdinLock < ' a > {
475
- StdinLock { inner : self . inner . lock ( ) . unwrap_or_else ( |e| e. into_inner ( ) ) }
476
- }
477
-
478
- /// Consumes this handle to the standard input stream, locking the
479
- /// shared global buffer associated with the stream and returning a
480
- /// readable guard.
481
- ///
482
- /// The lock is released when the returned guard goes out of scope. The
483
- /// returned guard also implements the [`Read`] and [`BufRead`] traits
484
- /// for accessing the underlying data.
485
- ///
486
- /// It is often simpler to directly get a locked handle using the
487
- /// [`stdin_locked`] function instead, unless nearby code also needs to
488
- /// use an unlocked handle.
489
- ///
490
- /// # Examples
491
- ///
492
- /// ```no_run
493
- /// #![feature(stdio_locked)]
494
- /// use std::io::{self, BufRead};
495
- ///
496
- /// fn main() -> io::Result<()> {
497
- /// let mut buffer = String::new();
498
- /// let mut handle = io::stdin().into_locked();
499
- ///
500
- /// handle.read_line(&mut buffer)?;
501
- /// Ok(())
502
- /// }
503
- /// ```
504
- #[ unstable( feature = "stdio_locked" , issue = "86845" ) ]
505
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
506
- pub fn into_locked ( self ) -> StdinLock < ' static > {
507
- self . lock_any ( )
508
- }
509
-
510
428
/// Consumes this handle and returns an iterator over input lines.
511
429
///
512
430
/// For detailed semantics of this method, see the documentation on
@@ -524,34 +442,10 @@ impl Stdin {
524
442
/// ```
525
443
#[ must_use = "`self` will be dropped if the result is not used" ]
526
444
#[ stable( feature = "stdin_forwarders" , since = "1.62.0" ) ]
527
- #[ cfg( not( target_os = "solana" ) ) ]
445
+ #[ cfg( not( any ( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
528
446
pub fn lines ( self ) -> Lines < StdinLock < ' static > > {
529
447
self . lock ( ) . lines ( )
530
448
}
531
-
532
- /// Consumes this handle and returns an iterator over input bytes,
533
- /// split at the specified byte value.
534
- ///
535
- /// For detailed semantics of this method, see the documentation on
536
- /// [`BufRead::split`].
537
- ///
538
- /// # Examples
539
- ///
540
- /// ```no_run
541
- /// #![feature(stdin_forwarders)]
542
- /// use std::io;
543
- ///
544
- /// let splits = io::stdin().split(b'-');
545
- /// for split in splits {
546
- /// println!("got a chunk: {}", String::from_utf8_lossy(&split.unwrap()));
547
- /// }
548
- /// ```
549
- #[ must_use = "`self` will be dropped if the result is not used" ]
550
- #[ unstable( feature = "stdin_forwarders" , issue = "87096" ) ]
551
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
552
- pub fn split ( self , byte : u8 ) -> Split < StdinLock < ' static > > {
553
- self . into_locked ( ) . split ( byte)
554
- }
555
449
}
556
450
557
451
#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
@@ -891,52 +785,13 @@ impl Stdout {
891
785
/// }
892
786
/// ```
893
787
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
894
- #[ cfg( not( target_os = "solana" ) ) ]
788
+ #[ cfg( not( any ( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
895
789
pub fn lock ( & self ) -> StdoutLock < ' static > {
896
790
// Locks this handle with 'static lifetime. This depends on the
897
791
// implementation detail that the underlying `ReentrantMutex` is
898
792
// static.
899
793
StdoutLock { inner : self . inner . lock ( ) }
900
794
}
901
-
902
- // Locks this handle with any lifetime. This depends on the
903
- // implementation detail that the underlying `ReentrantMutex` is
904
- // static.
905
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
906
- fn lock_any < ' a > ( & self ) -> StdoutLock < ' a > {
907
- StdoutLock { inner : self . inner . lock ( ) }
908
- }
909
-
910
- /// Consumes this handle to the standard output stream, locking the
911
- /// shared global buffer associated with the stream and returning a
912
- /// writable guard.
913
- ///
914
- /// The lock is released when the returned lock goes out of scope. The
915
- /// returned guard also implements the [`Write`] trait for writing data.
916
- ///
917
- /// It is often simpler to directly get a locked handle using the
918
- /// [`io::stdout_locked`] function instead, unless nearby code also
919
- /// needs to use an unlocked handle.
920
- ///
921
- /// # Examples
922
- ///
923
- /// ```no_run
924
- /// #![feature(stdio_locked)]
925
- /// use std::io::{self, Write};
926
- ///
927
- /// fn main() -> io::Result<()> {
928
- /// let mut handle = io::stdout().into_locked();
929
- ///
930
- /// handle.write_all(b"hello world")?;
931
- ///
932
- /// Ok(())
933
- /// }
934
- /// ```
935
- #[ unstable( feature = "stdio_locked" , issue = "86845" ) ]
936
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
937
- pub fn into_locked ( self ) -> StdoutLock < ' static > {
938
- self . lock_any ( )
939
- }
940
795
}
941
796
942
797
#[ stable( feature = "catch_unwind" , since = "1.9.0" ) ]
@@ -1198,36 +1053,6 @@ pub fn stderr() -> Stderr {
1198
1053
Stderr { }
1199
1054
}
1200
1055
1201
- /// Constructs a new locked handle to the standard error of the current
1202
- /// process.
1203
- ///
1204
- /// This handle is not buffered.
1205
- ///
1206
- /// ### Note: Windows Portability Consideration
1207
- /// When operating in a console, the Windows implementation of this stream does not support
1208
- /// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
1209
- /// an error.
1210
- ///
1211
- /// # Example
1212
- ///
1213
- /// ```no_run
1214
- /// #![feature(stdio_locked)]
1215
- /// use std::io::{self, Write};
1216
- ///
1217
- /// fn main() -> io::Result<()> {
1218
- /// let mut handle = io::stderr_locked();
1219
- ///
1220
- /// handle.write_all(b"hello world")?;
1221
- ///
1222
- /// Ok(())
1223
- /// }
1224
- /// ```
1225
- #[ unstable( feature = "stdio_locked" , issue = "86845" ) ]
1226
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
1227
- pub fn stderr_locked ( ) -> StderrLock < ' static > {
1228
- stderr ( ) . into_locked ( )
1229
- }
1230
-
1231
1056
impl Stderr {
1232
1057
/// Locks this handle to the standard error stream, returning a writable
1233
1058
/// guard.
@@ -1250,49 +1075,13 @@ impl Stderr {
1250
1075
/// }
1251
1076
/// ```
1252
1077
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1253
- #[ cfg( not( target_os = "solana" ) ) ]
1078
+ #[ cfg( not( any ( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
1254
1079
pub fn lock ( & self ) -> StderrLock < ' static > {
1255
1080
// Locks this handle with 'static lifetime. This depends on the
1256
1081
// implementation detail that the underlying `ReentrantMutex` is
1257
1082
// static.
1258
1083
StderrLock { inner : self . inner . lock ( ) }
1259
1084
}
1260
-
1261
- // Locks this handle with any lifetime. This depends on the
1262
- // implementation detail that the underlying `ReentrantMutex` is
1263
- // static.
1264
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
1265
- fn lock_any < ' a > ( & self ) -> StderrLock < ' a > {
1266
- StderrLock { inner : self . inner . lock ( ) }
1267
- }
1268
-
1269
- /// Locks and consumes this handle to the standard error stream,
1270
- /// returning a writable guard.
1271
- ///
1272
- /// The lock is released when the returned guard goes out of scope. The
1273
- /// returned guard also implements the [`Write`] trait for writing
1274
- /// data.
1275
- ///
1276
- /// # Examples
1277
- ///
1278
- /// ```
1279
- /// #![feature(stdio_locked)]
1280
- /// use std::io::{self, Write};
1281
- ///
1282
- /// fn foo() -> io::Result<()> {
1283
- /// let stderr = io::stderr();
1284
- /// let mut handle = stderr.into_locked();
1285
- ///
1286
- /// handle.write_all(b"hello world")?;
1287
- ///
1288
- /// Ok(())
1289
- /// }
1290
- /// ```
1291
- #[ unstable( feature = "stdio_locked" , issue = "86845" ) ]
1292
- #[ cfg( all( not( target_arch = "bpf" ) , not( target_arch = "sbf" ) ) ) ]
1293
- pub fn into_locked ( self ) -> StderrLock < ' static > {
1294
- self . lock_any ( )
1295
- }
1296
1085
}
1297
1086
1298
1087
#[ stable( feature = "catch_unwind" , since = "1.9.0" ) ]
0 commit comments