Trait otter_api_tests::shapelib::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, }));
Implementations on Foreign Types
Write an Ipv6Addr, conforming to the canonical style described by RFC 5952.
impl Display for OpenSSHKeyError
impl Display for OpenSSHKeyError
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
.
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<'a> Display for DecodeStringError<'a>
impl<'a> Display for DecodeStringError<'a>
impl<'a> Display for PercentEncode<'a>
impl<'a> Display for PercentEncode<'a>
Show the original glob pattern.
Display the serialization of this URL.
impl<'a, E> Display for PercentEncode<'a, E> where
E: EncodeSet,
impl<'a, E> Display for PercentEncode<'a, E> where
E: EncodeSet,
Formats the status code, including the canonical reason.
Example
assert_eq!(format!("{}", StatusCode::OK), "200 OK");
impl<T> Display for SendTimeoutError<T>
impl<T> Display for SendTimeoutError<T>
impl Display for LengthDelimitedCodecError
impl Display for LengthDelimitedCodecError
impl Display for AnyDelimiterCodecError
impl Display for AnyDelimiterCodecError
Implementors
impl Display for FlexiLoggerError
impl Display for FlexiLoggerError
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 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");
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");
Show the original glob pattern.
impl Display for otter_api_tests::zcoord::ParseError
impl Display for otter_api_tests::zcoord::ParseError
impl Display for RangeBackwards
impl Display for RangeBackwards
impl Display for TotallyUnboundedRange
impl Display for TotallyUnboundedRange
impl Display for InvalidPassword
impl Display for InvalidPassword
impl Display for CoordinateOverflow
impl Display for CoordinateOverflow
Display the serialization of this URL.
impl<'a> Display for Base64Display<'a>
impl<'a> Display for Base64Display<'a>
impl<'a, K, V> Display for otter_api_tests::hash_map::OccupiedError<'a, K, V> where
K: Debug,
V: Debug,
[src]
impl<'a, K, V> Display for otter_api_tests::hash_map::OccupiedError<'a, K, V> where
K: Debug,
V: Debug,
[src]impl<'a, R, G, T> Display for MappedReentrantMutexGuard<'a, R, G, T> where
T: 'a + Display + ?Sized,
G: 'a + GetThreadId,
R: 'a + RawMutex,
impl<'a, R, G, T> Display for MappedReentrantMutexGuard<'a, R, G, T> where
T: 'a + Display + ?Sized,
G: 'a + GetThreadId,
R: 'a + RawMutex,
impl<'a, R, G, T> Display for ReentrantMutexGuard<'a, R, G, T> where
T: 'a + Display + ?Sized,
G: 'a + GetThreadId,
R: 'a + RawMutex,
impl<'a, R, G, T> Display for ReentrantMutexGuard<'a, R, G, T> where
T: 'a + Display + ?Sized,
G: 'a + GetThreadId,
R: 'a + RawMutex,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::MappedMutexGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawMutex,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::MappedMutexGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawMutex,
impl<'a, R, T> Display for MappedRwLockReadGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for MappedRwLockReadGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for MappedRwLockWriteGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for MappedRwLockWriteGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::MutexGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawMutex,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::MutexGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawMutex,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::RwLockReadGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::RwLockReadGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for RwLockUpgradableReadGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLockUpgrade,
impl<'a, R, T> Display for RwLockUpgradableReadGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLockUpgrade,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::RwLockWriteGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, R, T> Display for otter_api_tests::imports::parking_lot::lock_api::RwLockWriteGuard<'a, R, T> where
T: 'a + Display + ?Sized,
R: 'a + RawRwLock,
impl<'a, T> Display for StyledValue<'a, T> where
T: Display,
impl<'a, T> Display for StyledValue<'a, T> where
T: Display,
impl<E> Display for ParseNotNanError<E> where
E: Display,
impl<E> Display for ParseNotNanError<E> where
E: Display,
impl<T> Display for SyncFailure<T> where
T: Display,
impl<T> Display for SyncFailure<T> where
T: Display,
impl<T> Display for OrderedFloat<T> where
T: Float + Display,
impl<T> Display for OrderedFloat<T> where
T: Float + Display,