Skip to content

Commit ccb4dd6

Browse files
committed
Move std::io::IoHandle to core::io
1 parent 3ce7e32 commit ccb4dd6

4 files changed

Lines changed: 23 additions & 16 deletions

File tree

library/alloc/src/io/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ pub use core::io::{
1717
};
1818
#[doc(hidden)]
1919
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
20-
pub use core::io::{OsFunctions, chain, take};
20+
pub use core::io::{IoHandle, OsFunctions, chain, take};

library/core/src/io/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,22 @@ pub use self::{
2727
error::{Custom, CustomOwner, OsFunctions},
2828
util::{chain, take},
2929
};
30+
31+
/// Marks that a type `T` can have IO traits such as [`Seek`], [`Write`], etc. automatically
32+
/// implemented for handle types like [`Arc`][arc] as well.
33+
///
34+
/// This trait should only be implemented for types where `<&T as Trait>::method(&mut &value, ..)`
35+
/// would be identical to `<T as Trait>::method(&mut value, ..)`.
36+
///
37+
/// [`File`][file] passes this test, as operations on `&File` and `File` both affect
38+
/// the same underlying file.
39+
/// `[u8]` fails, because any modification to `&mut &[u8]` would only affect a temporary
40+
/// and be lost after the method has been called.
41+
///
42+
/// [file]: ../../std/fs/struct.File.html
43+
/// [arc]: ../../alloc/sync/struct.Arc.html
44+
/// [`Write`]: ../../std/io/trait.Write.html
45+
/// [`Seek`]: ../../std/io/trait.Seek.html
46+
#[doc(hidden)]
47+
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
48+
pub trait IoHandle {}

library/std/src/fs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,8 @@ impl Seek for File {
15421542
(&*self).stream_position()
15431543
}
15441544
}
1545+
#[doc(hidden)]
1546+
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
15451547
impl crate::io::IoHandle for File {}
15461548

15471549
impl Dir {

library/std/src/io/mod.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ mod tests;
299299

300300
use core::slice::memchr;
301301

302+
pub(crate) use alloc_crate::io::IoHandle;
302303
use alloc_crate::io::OsFunctions;
303304
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
304305
pub use alloc_crate::io::RawOsError;
@@ -1914,21 +1915,6 @@ pub enum SeekFrom {
19141915
Current(#[stable(feature = "rust1", since = "1.0.0")] i64),
19151916
}
19161917

1917-
/// Marks that a type `T` can have IO traits such as [`Seek`], [`Write`], etc. automatically
1918-
/// implemented for handle types like [`Arc`][arc] as well.
1919-
///
1920-
/// This trait should only be implemented for types where `<&T as Trait>::method(&mut &value, ..)`
1921-
/// would be identical to `<T as Trait>::method(&mut value, ..)`.
1922-
///
1923-
/// [`File`][file] passes this test, as operations on `&File` and `File` both affect
1924-
/// the same underlying file.
1925-
/// `[u8]` fails, because any modification to `&mut &[u8]` would only affect a temporary
1926-
/// and be lost after the method has been called.
1927-
///
1928-
/// [file]: crate::fs::File
1929-
/// [arc]: crate::sync::Arc
1930-
pub(crate) trait IoHandle {}
1931-
19321918
fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) -> Result<usize> {
19331919
let mut read = 0;
19341920
loop {

0 commit comments

Comments
 (0)