Trait sp_std::fmt::Display1.0.0[][src]

pub trait Display {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description

Format trait for an empty format, {}.

Display is similar to Debug, but Display is for user-facing output, and so cannot be derived.

For more information on formatters, see the module-level documentation.

Examples

Implementing Display on a type:

use std::fmt;

struct Point {
    x: i32,
    y: i32,
}

impl fmt::Display for Point {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "({}, {})", self.x, self.y)
    }
}

let origin = Point { x: 0, y: 0 };

assert_eq!(format!("The origin is: {}", origin), "The origin is: (0, 0)");

Required methods

Formats the value using the given formatter.

Examples

use std::fmt;

struct Position {
    longitude: f32,
    latitude: f32,
}

impl fmt::Display for Position {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "({}, {})", self.longitude, self.latitude)
    }
}

assert_eq!("(1.987, 2.983)",
           format!("{}", Position { longitude: 1.987, latitude: 2.983, }));

Implementations on Foreign Types

Write an Ipv6Addr, conforming to the canonical style described by RFC 5952.

Implementors

impl<E: Error> Display for Error<E>

impl Display for Analysis

impl Display for BenchmarkParameter

impl Display for SizeType

impl Display for NsFormatter

impl Display for BenchmarkOutput

impl Display for DatabaseType

impl Display for DatabaseSize

impl Display for Error

impl Display for Public

impl Display for Error

impl Display for WasmExecutionMethod

impl Display for TracingReceiver

impl Display for NodeKeyType

impl Display for CryptoScheme

impl Display for OutputType

impl Display for ExecutionStrategy

impl Display for RpcMethods

impl Display for OffchainWorkerEnabled

impl Display for SyncMode

impl Display for Error

impl Display for MemorySize

impl Display for UsageInfo

impl Display for DatabaseSource

impl<B: BlockT> Display for Error<B> where
    B::Hash: Display + Debug

impl Display for Error

impl Display for Error

impl<B: BlockT> Display for Error<B> where
    B::Hash: Debug

impl<T> Display for Error<T> where
    T: Debug

impl<B: BlockT> Display for Error<B>

impl Display for Error

impl Display for WasmError

impl Display for FinalityProofError

impl Display for Error

impl Display for Error

impl Display for WarpSyncPhase

impl Display for RequestFailure

impl Display for BitswapError

impl Display for Role

impl Display for MultiaddrWithPeerId

impl Display for ParseErr

impl Display for Error

impl Display for SendRequestError

impl Display for UnsafeRpcError

impl Display for Error

impl Display for Error

impl Display for Error

impl Display for Error

impl Display for Error

impl Display for Health

impl Display for Error

impl<Block: BlockT> Display for Error<Block>

impl Display for Error

impl Display for Error

impl Display for Error

impl Display for Values

impl Display for Error

impl Display for Error

impl Display for ApiError

impl Display for Public

impl Display for Public

impl Display for Public

impl Display for FixedI64

impl Display for FixedI128

impl Display for FixedU128

impl Display for ApplyExtrinsicFailed

impl Display for Error

impl Display for Error

impl Display for Error

impl Display for NoProofRecorded

impl Display for Slot

impl Display for Ss58AddressFormat

impl Display for ParseError

impl Display for AccountId32

impl Display for CryptoTypePublicPair

impl<'a> Display for HexDisplay<'a>

impl Display for Public

impl Display for Public

impl Display for PublicError

impl Display for Public

impl Display for CodeNotFound

impl Display for DatabaseError

impl Display for Error

impl Display for Keyring

impl Display for ParseKeyringError

impl Display for Keyring

impl Display for Error

impl Display for Error

impl<Block: BlockT> Display for BlockId<Block>

impl<AccountId, AccountIndex> Display for MultiAddress<AccountId, AccountIndex> where
    AccountId: Debug,
    AccountIndex: Debug

impl Display for RuntimeString

impl Display for TransactionValidityError

impl Display for MultiSigner

impl Display for ExecutionError

impl Display for Timestamp

impl Display for InherentError

impl Display for Error

impl<L: TrieConfiguration> Display for Error<L>

impl Display for Error

impl Display for RuntimeVersion

impl Display for RpcTransactionError

impl Display for Error