sr_std/
lib.rs

1// Copyright 2017-2019 Parity Technologies (UK) Ltd.
2// This file is part of Substrate.
3
4// Substrate is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Substrate is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Substrate.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Lowest-abstraction level for the Substrate runtime: just exports useful primitives from std
18//! or core/alloc to be used with any code that depends on the runtime.
19
20#![cfg_attr(not(feature = "std"), no_std)]
21#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
22#![cfg_attr(not(feature = "std"), feature(alloc))]
23
24#![cfg_attr(feature = "std", doc = "Substrate runtime standard library as compiled when linked with Rust's standard library.")]
25#![cfg_attr(not(feature = "std"), doc = "Substrate's runtime standard library as compiled without Rust's standard library.")]
26
27#[macro_export]
28macro_rules! map {
29	($( $name:expr => $value:expr ),*) => (
30		vec![ $( ( $name, $value ) ),* ].into_iter().collect()
31	)
32}
33
34#[cfg(feature = "std")]
35include!("../with_std.rs");
36
37#[cfg(not(feature = "std"))]
38include!("../without_std.rs");
39
40/// Prelude of common useful imports.
41///
42/// This should include only things which are in the normal std prelude.
43pub mod prelude {
44	pub use crate::vec::Vec;
45	pub use crate::boxed::Box;
46	pub use crate::cmp::{Eq, PartialEq};
47	pub use crate::clone::Clone;
48
49	// Re-export `vec!` macro here, but not in `std` mode, since
50	// std's prelude already brings `vec!` into the scope.
51	#[cfg(not(feature = "std"))]
52	pub use crate::vec;
53}