std::fmt::Display - Rust (original) (raw)
Trait std::fmt::Display1.0.0 [โ] [src]
pub trait Display { fn fmt(&self, f: &mut Formatter) -> Result<(), Error>; }
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.
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 };
println!("The origin is: {}", origin);Run
fn [fmt](#tymethod.fmt)(&self, f: &mut [Formatter](../../std/fmt/struct.Formatter.html "struct std::fmt::Formatter")) -> [Result](../../std/result/enum.Result.html "enum std::result::Result")<[()](../primitive.unit.html), [Error](../../std/fmt/struct.Error.html "struct std::fmt::Error")>
Formats the value using the given formatter.
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)".to_owned(), format!("{}", Position { longitude: 1.987, latitude: 2.983, }));Run
impl [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") for [TryFromSliceError](../../core/array/struct.TryFromSliceError.html "struct core::array::TryFromSliceError")
[src]
impl [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") for [Utf8Lossy](../../std%5Funicode/lossy/struct.Utf8Lossy.html "struct std_unicode::lossy::Utf8Lossy")
[src]
impl Display for [ParseIntError](../../std/num/struct.ParseIntError.html "struct std::num::ParseIntError")
impl Display for [f32](../primitive.f32.html)
impl<'a, T> Display for [Ref](../../std/cell/struct.Ref.html "struct std::cell::Ref")<'a, T> where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl Display for [EscapeDefault](../../std/char/struct.EscapeDefault.html "struct std::char::EscapeDefault")
impl Display for [EscapeDebug](../../std/char/struct.EscapeDebug.html "struct std::char::EscapeDebug")
impl Display for [ParseBoolError](../../std/str/struct.ParseBoolError.html "struct std::str::ParseBoolError")
impl Display for [!](../primitive.never.html)
impl Display for [u64](../primitive.u64.html)
impl Display for [CharTryFromError](../../std/char/struct.CharTryFromError.html "struct std::char::CharTryFromError")
impl Display for [ParseFloatError](../../std/num/struct.ParseFloatError.html "struct std::num::ParseFloatError")
impl Display for [i8](../primitive.i8.html)
impl Display for [u8](../primitive.u8.html)
impl Display for [EscapeUnicode](../../std/char/struct.EscapeUnicode.html "struct std::char::EscapeUnicode")
impl Display for [BorrowMutError](../../std/cell/struct.BorrowMutError.html "struct std::cell::BorrowMutError")
impl Display for [bool](../primitive.bool.html)
impl Display for [str](../primitive.str.html)
impl Display for [u16](../primitive.u16.html)
impl<T> Display for [Wrapping](../../std/num/struct.Wrapping.html "struct std::num::Wrapping")<T> where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display"),
impl Display for [u32](../primitive.u32.html)
impl Display for [Utf8Error](../../std/str/struct.Utf8Error.html "struct std::str::Utf8Error")
impl Display for [TryFromIntError](../../std/num/struct.TryFromIntError.html "struct std::num::TryFromIntError")
impl Display for [Infallible](../../std/convert/enum.Infallible.html "enum std::convert::Infallible")
impl Display for std::fmt::[Error](../../std/fmt/struct.Error.html "struct std::fmt::Error")
impl<'a, T> Display for [&'a mut ](../primitive.reference.html)T where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl Display for [i16](../primitive.i16.html)
impl Display for [i32](../primitive.i32.html)
impl Display for [isize](../primitive.isize.html)
impl Display for [f64](../primitive.f64.html)
impl<'a, T> Display for [&'a ](../primitive.reference.html)T where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl Display for [char](../primitive.char.html)
impl Display for [BorrowError](../../std/cell/struct.BorrowError.html "struct std::cell::BorrowError")
impl Display for [usize](../primitive.usize.html)
impl<'a> Display for [Arguments](../../std/fmt/struct.Arguments.html "struct std::fmt::Arguments")<'a>
impl Display for [i64](../primitive.i64.html)
impl Display for [ParseCharError](../../std/char/struct.ParseCharError.html "struct std::char::ParseCharError")
impl<'a, T> Display for [RefMut](../../std/cell/struct.RefMut.html "struct std::cell::RefMut")<'a, T> where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl Display for [u128](../primitive.u128.html)
impl Display for [i128](../primitive.i128.html)
impl Display for [String](../../std/string/struct.String.html "struct std:๐งต:String")
impl<T> Display for [Arc](../../std/sync/struct.Arc.html "struct std::sync::Arc")<T> where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl Display for [AllocErr](../../std/heap/enum.AllocErr.html "enum std::heap::AllocErr")
impl Display for [ParseError](../../std/string/enum.ParseError.html "enum std:๐งต:ParseError")
impl<'a, B> Display for [Cow](../../std/borrow/enum.Cow.html "enum std::borrow::Cow")<'a, B> where B: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + [ToOwned](../../std/borrow/trait.ToOwned.html "trait std::borrow::ToOwned") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"), <B as [ToOwned](../../std/borrow/trait.ToOwned.html "trait std::borrow::ToOwned")>::[Owned](../../std/borrow/trait.ToOwned.html#associatedtype.Owned "type std::borrow::ToOwned::Owned"): [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display"),
impl Display for [CannotReallocInPlace](../../std/heap/struct.CannotReallocInPlace.html "struct std::heap::CannotReallocInPlace")
impl Display for [FromUtf8Error](../../std/string/struct.FromUtf8Error.html "struct std:๐งต:FromUtf8Error")
impl Display for [FromUtf16Error](../../std/string/struct.FromUtf16Error.html "struct std:๐งต:FromUtf16Error")
impl<T> Display for [Box](../../std/boxed/struct.Box.html "struct std::boxed::Box")<T> where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl<T> Display for [Rc](../../std/rc/struct.Rc.html "struct std::rc::Rc")<T> where T: [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") + ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized"),
impl Display for [ToUppercase](../../std/char/struct.ToUppercase.html "struct std::char::ToUppercase")
impl Display for [ToLowercase](../../std/char/struct.ToLowercase.html "struct std::char::ToLowercase")
impl Display for [DecodeUtf16Error](../../std/char/struct.DecodeUtf16Error.html "struct std::char::DecodeUtf16Error")
impl Display for [AccessError](../../std/thread/struct.AccessError.html "struct std::thread::AccessError")
impl Display for [VarError](../../std/env/enum.VarError.html "enum std::env::VarError")
impl Display for [JoinPathsError](../../std/env/struct.JoinPathsError.html "struct std::env::JoinPathsError")
impl Display for [NulError](../../std/ffi/struct.NulError.html "struct std::ffi::NulError")
impl Display for [FromBytesWithNulError](../../std/ffi/struct.FromBytesWithNulError.html "struct std::ffi::FromBytesWithNulError")
impl Display for [IntoStringError](../../std/ffi/struct.IntoStringError.html "struct std::ffi::IntoStringError")
impl<W> Display for [IntoInnerError](../../std/io/struct.IntoInnerError.html "struct std::io::IntoInnerError")<W>
impl Display for std::io::[Error](../../std/io/struct.Error.html "struct std::io::Error")
impl Display for [CharsError](../../std/io/enum.CharsError.html "enum std::io::CharsError")
impl Display for [IpAddr](../../std/net/enum.IpAddr.html "enum std:๐ฅ :IpAddr")
impl Display for [Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:๐ฅ :Ipv4Addr")
impl Display for [Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:๐ฅ :Ipv6Addr")
impl Display for [SocketAddr](../../std/net/enum.SocketAddr.html "enum std:๐ฅ :SocketAddr")
impl Display for [SocketAddrV4](../../std/net/struct.SocketAddrV4.html "struct std:๐ฅ :SocketAddrV4")
impl Display for [SocketAddrV6](../../std/net/struct.SocketAddrV6.html "struct std:๐ฅ :SocketAddrV6")
impl Display for [AddrParseError](../../std/net/struct.AddrParseError.html "struct std:๐ฅ :AddrParseError")
impl<'a> Display for [Display](../../std/path/struct.Display.html "struct std::path::Display")<'a>
impl Display for [StripPrefixError](../../std/path/struct.StripPrefixError.html "struct std::path::StripPrefixError")
impl Display for [ExitStatus](../../std/process/struct.ExitStatus.html "struct std::process::ExitStatus")
impl<T> Display for [SendError](../../std/sync/mpsc/struct.SendError.html "struct std::sync::mpsc::SendError")<T>
impl<T> Display for [TrySendError](../../std/sync/mpsc/enum.TrySendError.html "enum std::sync::mpsc::TrySendError")<T>
impl Display for [RecvError](../../std/sync/mpsc/struct.RecvError.html "struct std::sync::mpsc::RecvError")
impl Display for [TryRecvError](../../std/sync/mpsc/enum.TryRecvError.html "enum std::sync::mpsc::TryRecvError")
impl Display for [RecvTimeoutError](../../std/sync/mpsc/enum.RecvTimeoutError.html "enum std::sync::mpsc::RecvTimeoutError")
impl<'a, T: ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized") + [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display")> Display for [MutexGuard](../../std/sync/struct.MutexGuard.html "struct std::sync::MutexGuard")<'a, T>
impl<'a, T: ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized") + [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display")> Display for [RwLockReadGuard](../../std/sync/struct.RwLockReadGuard.html "struct std::sync::RwLockReadGuard")<'a, T>
impl<'a, T: ?[Sized](../../std/marker/trait.Sized.html "trait std:๐:Sized") + [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display")> Display for [RwLockWriteGuard](../../std/sync/struct.RwLockWriteGuard.html "struct std::sync::RwLockWriteGuard")<'a, T>
impl Display for [SystemTimeError](../../std/time/struct.SystemTimeError.html "struct std::time::SystemTimeError")
impl<T> Display for [PoisonError](../../std/sync/struct.PoisonError.html "struct std::sync::PoisonError")<T>
impl<T> Display for [TryLockError](../../std/sync/enum.TryLockError.html "enum std::sync::TryLockError")<T>