Trait frame_support::dispatch::fmt::Display 1.0.0[−][src]
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, }));
Trait Implementations
Implementations on Foreign Types
Write an Ipv6Addr, conforming to the canonical style described by RFC 5952.
impl Display for Regex
impl Display for Regex
impl Display for Regex
impl Display for Regex
impl Display for Ast
impl Display for Ast
Print a display representation of this Ast.
This does not preserve any of the original whitespace formatting that may have originally been present in the concrete syntax from which this Ast was generated.
This implementation uses constant stack space and heap space proportional
to the size of the Ast
.
impl Display for Hir
impl Display for Hir
Print a display representation of this Hir.
The result of this is a valid regular expression pattern string.
This implementation uses constant stack space and heap space proportional
to the size of the Hir
.
Display a JSON value as a string.
let json = json!({ "city": "London", "street": "10 Downing Street" }); // Compact format: // // {"city":"London","street":"10 Downing Street"} let compact = format!("{}", json); assert_eq!(compact, "{\"city\":\"London\",\"street\":\"10 Downing Street\"}"); // Pretty format: // // { // "city": "London", // "street": "10 Downing Street" // } let pretty = format!("{:#}", json); assert_eq!(pretty, "{\n \"city\": \"London\",\n \"street\": \"10 Downing Street\"\n}");
The Display
output of the naive date and time dt
is the same as
dt.format("%Y-%m-%d %H:%M:%S%.f")
.
It should be noted that, for leap seconds not on the minute boundary, it may print a representation not distinguishable from non-leap seconds. This doesn’t matter in practice, since such leap seconds never happened. (By the time of the first leap second on 1972-06-30, every time zone offset around the world has standardized to the 5-minute alignment.)
Example
use chrono::NaiveDate; let dt = NaiveDate::from_ymd(2016, 11, 15).and_hms(7, 39, 24); assert_eq!(format!("{}", dt), "2016-11-15 07:39:24");
Leap seconds may also be used.
let dt = NaiveDate::from_ymd(2015, 6, 30).and_hms_milli(23, 59, 59, 1_500); assert_eq!(format!("{}", dt), "2015-06-30 23:59:60.500");
The Display
output of the naive time t
is the same as
t.format("%H:%M:%S%.f")
.
The string printed can be readily parsed via the parse
method on str
.
It should be noted that, for leap seconds not on the minute boundary, it may print a representation not distinguishable from non-leap seconds. This doesn’t matter in practice, since such leap seconds never happened. (By the time of the first leap second on 1972-06-30, every time zone offset around the world has standardized to the 5-minute alignment.)
Example
use chrono::NaiveTime; assert_eq!(format!("{}", NaiveTime::from_hms(23, 56, 4)), "23:56:04"); assert_eq!(format!("{}", NaiveTime::from_hms_milli(23, 56, 4, 12)), "23:56:04.012"); assert_eq!(format!("{}", NaiveTime::from_hms_micro(23, 56, 4, 1234)), "23:56:04.001234"); assert_eq!(format!("{}", NaiveTime::from_hms_nano(23, 56, 4, 123456)), "23:56:04.000123456");
Leap seconds may also be used.
assert_eq!(format!("{}", NaiveTime::from_hms_milli(6, 59, 59, 1_500)), "06:59:60.500");
The Display
output of the naive date d
is the same as
d.format("%Y-%m-%d")
.
The string printed can be readily parsed via the parse
method on str
.
Example
use chrono::NaiveDate; assert_eq!(format!("{}", NaiveDate::from_ymd(2015, 9, 5)), "2015-09-05"); assert_eq!(format!("{}", NaiveDate::from_ymd( 0, 1, 1)), "0000-01-01"); assert_eq!(format!("{}", NaiveDate::from_ymd(9999, 12, 31)), "9999-12-31");
ISO 8601 requires an explicit sign for years before 1 BCE or after 9999 CE.
assert_eq!(format!("{}", NaiveDate::from_ymd( -1, 1, 1)), "-0001-01-01"); assert_eq!(format!("{}", NaiveDate::from_ymd(10000, 12, 31)), "+10000-12-31");
impl<T, Item> Display for ReuniteError<T, Item>
impl<T, Item> Display for ReuniteError<T, Item>
impl<T, E> Display for TrieError<T, E> where
T: MaybeDebug,
E: MaybeDebug,
impl<T, E> Display for TrieError<T, E> where
T: MaybeDebug,
E: MaybeDebug,
impl<R, Offset> Display for LineInstruction<R, Offset> where
R: Reader<Offset = Offset>,
Offset: ReaderOffset,
impl<R, Offset> Display for LineInstruction<R, Offset> where
R: Reader<Offset = Offset>,
Offset: ReaderOffset,
impl<AccountId, AccountIndex> Display for MultiAddress<AccountId, AccountIndex> where
AccountId: Debug,
AccountIndex: Debug,
impl<AccountId, AccountIndex> Display for MultiAddress<AccountId, AccountIndex> where
AccountId: Debug,
AccountIndex: Debug,
Implementors
impl<E: Error> Display for Error<E>
impl<E: Error> Display for Error<E>
impl Display for Analysis
impl Display for Analysis
impl Display for BenchmarkParameter
impl Display for BenchmarkParameter
impl Display for SizeType
impl Display for SizeType
impl Display for NsFormatter
impl Display for NsFormatter
impl Display for BenchmarkOutput
impl Display for BenchmarkOutput
impl Display for DatabaseType
impl Display for DatabaseType
impl Display for DatabaseSize
impl Display for DatabaseSize
impl Display for Error
impl Display for Error
impl Display for Public
impl Display for Public
impl Display for Error
impl Display for Error
impl Display for WasmExecutionMethod
impl Display for WasmExecutionMethod
impl Display for TracingReceiver
impl Display for TracingReceiver
impl Display for NodeKeyType
impl Display for NodeKeyType
impl Display for CryptoScheme
impl Display for CryptoScheme
impl Display for OutputType
impl Display for OutputType
impl Display for ExecutionStrategy
impl Display for ExecutionStrategy
impl Display for RpcMethods
impl Display for RpcMethods
impl Display for OffchainWorkerEnabled
impl Display for OffchainWorkerEnabled
impl Display for SyncMode
impl Display for SyncMode
impl Display for Error
impl Display for Error
impl Display for MemorySize
impl Display for MemorySize
impl Display for UsageInfo
impl Display for UsageInfo
impl Display for DatabaseSource
impl Display for DatabaseSource
impl<B: BlockT> Display for Error<B> where
B::Hash: Display + Debug,
impl<B: BlockT> Display for Error<B> where
B::Hash: Display + Debug,
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl<B: BlockT> Display for Error<B> where
B::Hash: Debug,
impl<B: BlockT> Display for Error<B> where
B::Hash: Debug,
impl<T> Display for Error<T> where
T: Debug,
impl<T> Display for Error<T> where
T: Debug,
impl<B: BlockT> Display for Error<B>
impl<B: BlockT> Display for Error<B>
impl Display for Error
impl Display for Error
impl Display for WasmError
impl Display for WasmError
impl Display for FinalityProofError
impl Display for FinalityProofError
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for WarpSyncPhase
impl Display for WarpSyncPhase
impl Display for RequestFailure
impl Display for RequestFailure
impl Display for BitswapError
impl Display for BitswapError
impl Display for Role
impl Display for Role
impl Display for MultiaddrWithPeerId
impl Display for MultiaddrWithPeerId
impl Display for ParseErr
impl Display for ParseErr
impl Display for Error
impl Display for Error
impl Display for SendRequestError
impl Display for SendRequestError
impl Display for UnsafeRpcError
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 Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Health
impl Display for Health
impl Display for Error
impl Display for Error
impl<Block: BlockT> Display for Error<Block>
impl<Block: BlockT> Display for Error<Block>
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Values
impl Display for Values
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for ApiError
impl Display for ApiError
impl Display for Public
impl Display for Public
impl Display for Public
impl Display for Public
impl Display for Public
impl Display for Public
impl Display for FixedI64
impl Display for FixedI64
impl Display for FixedI128
impl Display for FixedI128
impl Display for FixedU128
impl Display for FixedU128
impl Display for ApplyExtrinsicFailed
impl Display for ApplyExtrinsicFailed
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for NoProofRecorded
impl Display for NoProofRecorded
impl Display for Slot
impl Display for Slot
impl Display for Ss58AddressFormat
impl Display for Ss58AddressFormat
impl Display for ParseError
impl Display for ParseError
impl Display for AccountId32
impl Display for AccountId32
impl Display for CryptoTypePublicPair
impl Display for CryptoTypePublicPair
impl<'a> Display for HexDisplay<'a>
impl<'a> Display for HexDisplay<'a>
impl Display for Public
impl Display for Public
impl Display for Public
impl Display for Public
impl Display for PublicError
impl Display for PublicError
impl Display for Public
impl Display for Public
impl Display for CodeNotFound
impl Display for CodeNotFound
impl Display for DatabaseError
impl Display for DatabaseError
impl Display for Error
impl Display for Error
impl Display for Keyring
impl Display for Keyring
impl Display for ParseKeyringError
impl Display for ParseKeyringError
impl Display for Keyring
impl Display for Keyring
impl Display for Error
impl Display for Error
impl Display for Error
impl Display for Error
impl<Block: BlockT> Display for BlockId<Block>
impl<Block: BlockT> Display for BlockId<Block>
impl<AccountId, AccountIndex> Display for MultiAddress<AccountId, AccountIndex> where
AccountId: Debug,
AccountIndex: Debug,
impl<AccountId, AccountIndex> Display for MultiAddress<AccountId, AccountIndex> where
AccountId: Debug,
AccountIndex: Debug,
impl Display for RuntimeString
impl Display for RuntimeString
impl Display for TransactionValidityError
impl Display for TransactionValidityError
impl Display for MultiSigner
impl Display for MultiSigner
impl Display for ExecutionError
impl Display for ExecutionError
impl Display for Timestamp
impl Display for Timestamp
impl Display for InherentError
impl Display for InherentError
impl Display for Error
impl Display for Error
impl<L: TrieConfiguration> Display for Error<L>
impl<L: TrieConfiguration> Display for Error<L>
impl Display for Error
impl Display for Error
impl Display for RuntimeVersion
impl Display for RuntimeVersion
impl Display for RpcTransactionError
impl Display for RpcTransactionError
impl Display for Error
impl Display for Error