From a0ade883b69ab0f7bbc8b6198b6795855d8e00f7 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 9 Sep 2023 23:31:48 +0000 Subject: [PATCH] [IO] Move io module into selected re-exports In the coming commits we'll move our `io` module to having its own implementations of the usual I/O traits and structs. Here we first move to re-exporting only exactly what we need, allowing us to whittle the list down from a fixed set. --- io/src/lib.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/io/src/lib.rs b/io/src/lib.rs index 766dce62..e09557a1 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -21,12 +21,25 @@ #[cfg(all(not(feature = "std"), not(feature = "core2")))] compile_error!("At least one of std or core2 must be enabled"); -#[cfg(feature = "std")] -pub use std::io; #[cfg(feature = "std")] pub use std::error; - -#[cfg(not(feature = "std"))] -pub use core2::io; #[cfg(not(feature = "std"))] pub use core2::error; + +#[cfg(any(feature = "alloc", feature = "std"))] +extern crate alloc; + +/// Standard I/O stream definitions which are API-equivalent to `std`'s `io` module. See +/// [`std::io`] for more info. +pub mod io { + #[cfg(all(not(feature = "std"), not(feature = "core2")))] + compile_error!("At least one of std or core2 must be enabled"); + + #[cfg(feature = "std")] + pub use std::io::{Read, Write, Cursor, Take, IoSlice, Error, ErrorKind, Result}; + + #[cfg(not(feature = "std"))] + pub use core2::io::{Read, Write, Cursor, Take, Error, ErrorKind, Result}; + + +}