1//! Re-exports either the Rust `std` library or `core` and `alloc` when `std` is
2//! disabled.
3//!
4//! `crate::stdlib::...` should be used rather than `std::` when adding code that
5//! will be available with the standard library disabled.
6//!
7//! Note that this module is called `stdlib` rather than `std`, as Rust 1.34.0
8//! does not permit redefining the name `stdlib` (although this works on the
9//! latest stable Rust).
10#[cfg(feature = "std")]
11pub(crate) use std::*;
12
13#[cfg(not(feature = "std"))]
14pub(crate) use self::no_std::*;
15
16#[cfg(not(feature = "std"))]
17mod no_std {
18 // We pre-emptively export everything from libcore/liballoc, (even modules
19 // we aren't using currently) to make adding new code easier. Therefore,
20 // some of these imports will be unused.
21 #![allow(unused_imports)]
22
23 pub(crate) use core::{
24 any, array, ascii, cell, char, clone, cmp, convert, default, f32, f64, ffi, future, hash,
25 hint, i128, i16, i8, isize, iter, marker, mem, num, ops, option, pin, ptr, result, task,
26 time, u128, u16, u32, u8, usize,
27 };
28
29 pub(crate) use alloc::{boxed, collections, rc, string, vec};
30
31 pub(crate) mod borrow {
32 pub(crate) use alloc::borrow::*;
33 pub(crate) use core::borrow::*;
34 }
35
36 pub(crate) mod fmt {
37 pub(crate) use alloc::fmt::*;
38 pub(crate) use core::fmt::*;
39 }
40
41 pub(crate) mod slice {
42 pub(crate) use alloc::slice::*;
43 pub(crate) use core::slice::*;
44 }
45
46 pub(crate) mod str {
47 pub(crate) use alloc::str::*;
48 pub(crate) use core::str::*;
49 }
50
51 pub(crate) mod sync {
52 pub(crate) use alloc::sync::*;
53 pub(crate) use core::sync::*;
54 }
55}
56