more idiomatic std features

This commit is contained in:
Robert Habermeier
2018-01-30 19:28:57 +01:00
parent a68b187f4d
commit 8e6cb1b6e2
18 changed files with 30 additions and 30 deletions
+1
View File
@@ -748,6 +748,7 @@ dependencies = [
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fixed-hash 0.1.0 (git+https://github.com/paritytech/primitives.git)",
"polkadot-runtime-codec 0.1.0",
"polkadot-serializer 0.1.0",
"pretty_assertions 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
+2 -3
View File
@@ -9,6 +9,5 @@ runtime-std = { path = "./std", version = "0.1" }
rustc-hex = "1.0"
[features]
default = ["with-std"]
with-std = []
without-std = ["polkadot-runtime-codec/no-std"]
default = ["std"]
std = ["polkadot-runtime-codec/std"]
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! The with-std support functions for the runtime.
//! The std support functions for the runtime.
#[macro_use]
extern crate environmental;
+2 -1
View File
@@ -15,6 +15,7 @@ untrusted = "0.5"
twox-hash = "1.1.0"
byteorder = "1.1"
blake2-rfc = "0.2.18"
polkadot-runtime-codec = { path = "../runtime-codec", version = "0.1" }
[dev-dependencies]
polkadot-serializer = { path = "../serializer", version = "0.1" }
@@ -22,4 +23,4 @@ pretty_assertions = "0.4"
[features]
default = ["std"]
std = ["uint/std", "fixed-hash/std"]
std = ["uint/std", "fixed-hash/std", "polkadot-runtime-codec/std"]
+2 -2
View File
@@ -7,5 +7,5 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
[features]
no-std = []
default = []
std = []
default = ["std"]
+3 -3
View File
@@ -17,8 +17,8 @@
//! Implements the serialization and deserialization codec for polkadot runtime
//! values.
#![cfg_attr(feature = "no-std", no_std)]
#![cfg_attr(feature = "no-std", feature(alloc))]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
mod endiansensitive;
mod slicable;
@@ -32,7 +32,7 @@ pub use self::streamreader::StreamReader;
pub use self::joiner::Joiner;
pub use self::keyedvec::KeyedVec;
#[cfg(feature = "no-std")]
#[cfg(not(feature = "std"))]
mod std {
extern crate alloc;
+3 -4
View File
@@ -7,10 +7,9 @@ authors = ["Parity Technologies <admin@parity.io>"]
crate-type = ["cdylib"]
[dependencies]
polkadot-runtime-codec = { path = "../../runtime-codec", version = "0.1" }
polkadot-runtime-codec = { path = "../../runtime-codec", version = "0.1", default-features = false}
runtime-std = { path = "../std", version = "0.1" }
[features]
default = ["without-std"]
with-std = []
without-std = ["polkadot-runtime-codec/no-std"]
default = []
std = ["polkadot-runtime-codec/std"]
+2 -2
View File
@@ -16,12 +16,12 @@
//! The Polkadot runtime. This can be compiled with #[no_std], ready for Wasm.
#![cfg_attr(feature = "without-std", no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
#[macro_use]
extern crate runtime_std;
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
extern crate rustc_hex;
extern crate polkadot_runtime_codec as codec;
@@ -21,7 +21,7 @@ use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
use primitives::{Header, UncheckedTransaction};
/// A Polkadot relay chain block.
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct Block {
/// The header of the block.
pub header: Header,
@@ -19,7 +19,7 @@
use runtime_std::prelude::*;
#[derive(Clone, Default)]
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
/// The digest of a block, useful for light-clients.
pub struct Digest {
/// All logs that have happened in the block.
@@ -22,7 +22,7 @@ use runtime::{staking, session, timestamp, governance};
/// Public functions that can be dispatched to.
#[derive(Clone, Copy)]
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
#[repr(u8)]
pub enum Function {
StakingStake = 0,
@@ -22,7 +22,7 @@ use runtime_std::mem;
use primitives::{BlockNumber, Hash, Digest};
#[derive(Clone)]
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
/// The header for a block.
pub struct Header {
/// The parent block's "hash" (actually the Blake2-256 hash of its serialised header).
@@ -24,7 +24,7 @@ use runtime::{system, governance, staking, session};
/// Internal functions that can be dispatched to.
#[derive(Clone, Copy)]
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
#[repr(u8)]
pub enum InternalFunction {
SystemSetCode = 0,
@@ -56,7 +56,7 @@ impl InternalFunction {
}
/// An internal function.
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct Proposal {
/// The priviledged function to call.
pub function: InternalFunction,
@@ -22,7 +22,7 @@ use primitives::{AccountID, TxOrder, Function};
use runtime_std::mem;
/// A vetted and verified transaction from the external world.
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
#[cfg_attr(feature = "std", derive(PartialEq, Debug))]
pub struct Transaction {
/// Who signed it (note this is not a signature).
pub signed: AccountID,
@@ -21,7 +21,7 @@ use runtime_std::prelude::*;
use codec::{Slicable, NonTrivialSlicable, StreamReader, Joiner};
use primitives::Transaction;
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
use std::fmt;
/// A transactions right from the external world. Unchecked.
@@ -40,14 +40,14 @@ impl UncheckedTransaction {
}
}
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
impl PartialEq for UncheckedTransaction {
fn eq(&self, other: &Self) -> bool {
self.signature.iter().eq(other.signature.iter()) && self.transaction == other.transaction
}
}
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
impl fmt::Debug for UncheckedTransaction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "UncheckedTransaction({:?})", self.transaction)
@@ -19,16 +19,16 @@
mod environment;
pub mod storage;
mod hashable;
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
mod statichex;
#[macro_use]
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
mod testing;
pub use self::environment::with_env;
pub use self::storage::StorageVec;
pub use self::hashable::Hashable;
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
pub use self::statichex::{StaticHexConversion, StaticHexInto};
#[cfg(feature = "with-std")]
#[cfg(feature = "std")]
pub use self::testing::{AsBytesRef, HexDisplay, TestExternalities, one, two};