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
+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};