pub trait Display {
// Required method
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description
Format trait for an empty format, {}
.
Implementing this trait for a type will automatically implement the
ToString
trait for the type, allowing the usage
of the .to_string()
method. Prefer implementing
the Display
trait for a type, rather than ToString
.
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§
sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
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§
Implementors§
impl Display for ChmapPosition
impl Display for SelemChannelId
impl Display for Format
impl Display for LoadingError
impl Display for async_broadcast::RecvError
impl Display for async_broadcast::TryRecvError
impl Display for async_channel::TryRecvError
impl Display for ParseAlphabetError
impl Display for base64::decode::DecodeError
impl Display for DecodeSliceError
impl Display for EncodeSliceError
impl Display for CheckedCastError
impl Display for PodCastError
impl Display for calloop::error::Error
impl Display for codespan_reporting::files::Error
impl Display for PopError
impl Display for BuildStreamError
impl Display for DefaultStreamConfigError
impl Display for DeviceNameError
impl Display for DevicesError
impl Display for PauseStreamError
impl Display for PlayStreamError
impl Display for cpal::error::StreamError
impl Display for SupportedStreamConfigsError
impl Display for SampleFormat
impl Display for crossbeam_channel::err::RecvTimeoutError
impl Display for crossbeam_channel::err::TryRecvError
impl Display for CursorIcon
impl Display for DecodeKind
impl Display for DlError
impl Display for DistanceModelError
impl Display for gilrs::ff::Error
impl Display for gilrs::gamepad::Error
impl Display for MappingError
impl Display for gilrs_core::Error
impl Display for gltf::binary::Error
impl Display for gltf::Error
impl Display for gltf_json::validation::Error
impl Display for gpu_alloc::error::AllocationError
impl Display for MapError
impl Display for gpu_descriptor::allocator::AllocationError
impl Display for ImageError
impl Display for ImageFormatHint
impl Display for image::flat::Error
impl Display for khronos_egl::egl1_0::Error
impl Display for khronos_egl::Version
impl Display for ktx2::error::ParseError
impl Display for AudioReadError
impl Display for VorbisError
impl Display for HeaderReadError
impl Display for libloading::error::Error
impl Display for libloading::error::Error
impl Display for log::Level
impl Display for log::LevelFilter
impl Display for naga::back::glsl::Error
impl Display for naga::back::glsl::Version
impl Display for naga::back::hlsl::EntryPointError
impl Display for naga::back::hlsl::Error
impl Display for naga::back::msl::EntryPointError
impl Display for naga::back::msl::Error
impl Display for naga::back::spv::Error
impl Display for naga::back::wgsl::Error
impl Display for ConstantEvaluatorError
impl Display for IndexableLengthError
impl Display for LayoutErrorInner
impl Display for naga::proc::typifier::ResolveError
impl Display for ComposeError
impl Display for ConstantError
impl Display for ValidationError
impl Display for ConstExpressionError
impl Display for ExpressionError
impl Display for LiteralError
impl Display for CallError
impl Display for FunctionError
impl Display for LocalVariableError
impl Display for naga::valid::interface::EntryPointError
impl Display for GlobalVariableError
impl Display for VaryingError
impl Display for Disalignment
impl Display for TypeError
impl Display for ComposerErrorInner
impl Display for RedirectError
impl Display for nix::errno::consts::Errno
impl Display for nix::errno::consts::Errno
impl Display for Signal
impl Display for OggReadError
impl Display for BlendOp
impl Display for DisposeOp
impl Display for png::decoder::stream::DecodingError
impl Display for png::encoder::EncodingError
impl Display for HandleError
impl Display for RectanglePackError
impl Display for regex::error::Error
impl Display for regex_automata::dfa::automaton::StartError
impl Display for regex_automata::hybrid::error::StartError
impl Display for regex_syntax::ast::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 regex_syntax::ast::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 regex_syntax::ast::ErrorKind
impl Display for regex_syntax::ast::ErrorKind
impl Display for regex_syntax::error::Error
impl Display for regex_syntax::error::Error
impl Display for regex_syntax::hir::ErrorKind
impl Display for regex_syntax::hir::ErrorKind
impl Display for DecoderError
impl Display for Mp4Type
impl Display for PlayError
impl Display for rodio::stream::StreamError
impl Display for BlockType
impl Display for LiteralsSectionParseError
impl Display for LiteralsSectionType
impl Display for SequencesHeaderParseError
impl Display for GetBitsError
impl Display for BlockHeaderReadError
impl Display for BlockSizeError
impl Display for BlockTypeError
impl Display for DecodeBlockContentError
impl Display for DecompressBlockError
impl Display for DecodebufferError
impl Display for DictionaryDecodeError
impl Display for DecompressLiteralsError
impl Display for ExecuteSequencesError
impl Display for DecodeSequenceError
impl Display for FrameDescriptorError
impl Display for FrameHeaderError
impl Display for ReadFrameHeaderError
impl Display for FrameDecoderError
impl Display for FSEDecoderError
impl Display for FSETableError
impl Display for HuffmanDecoderError
impl Display for HuffmanTableError
impl Display for serde_json::value::Value
impl Display for DataOfferError
impl Display for smithay_client_toolkit::error::GlobalError
impl Display for Capability
impl Display for SeatError
impl Display for PointerThemeError
impl Display for CreatePoolError
impl Display for PoolError
impl Display for ActivateSlotError
impl Display for smithay_client_toolkit::shm::slot::CreateBufferError
impl Display for Align
impl Display for Fill
impl Display for PathOp
impl Display for Stroke
impl Display for TaffyError
impl Display for FaceParsingError
impl Display for Language
impl Display for Variant
impl Display for WaylandError
impl Display for InitError
impl Display for wayland_client::conn::ConnectError
impl Display for wayland_client::DispatchError
impl Display for wayland_client::globals::BindError
impl Display for wayland_client::globals::GlobalError
impl Display for wgpu::Error
impl Display for wgpu::SurfaceError
impl Display for wgpu_core::binding_model::BindError
impl Display for BindGroupLayoutEntryError
impl Display for BindingZone
impl Display for CreateBindGroupError
impl Display for CreateBindGroupLayoutError
impl Display for CreatePipelineLayoutError
impl Display for GetBindGroupLayoutError
impl Display for PushConstantUploadError
impl Display for CreateRenderBundleError
impl Display for ExecutionError
impl Display for ClearError
impl Display for ComputePassErrorInner
impl Display for wgpu_core::command::compute::DispatchError
impl Display for DrawError
impl Display for RenderCommandError
impl Display for CommandEncoderError
impl Display for PassErrorScope
impl Display for QueryError
impl Display for QueryUseError
impl Display for wgpu_core::command::query::ResolveError
impl Display for AttachmentErrorLocation
impl Display for ColorAttachmentError
impl Display for RenderPassErrorInner
impl Display for CopyError
impl Display for TransferError
impl Display for wgpu_core::device::DeviceError
impl Display for RenderPassCompatibilityError
impl Display for WaitIdleError
impl Display for QueueSubmitError
impl Display for QueueWriteError
impl Display for CreateDeviceError
impl Display for GetSurfaceSupportError
impl Display for IsSurfaceSupportedError
impl Display for RequestAdapterError
impl Display for wgpu_core::instance::RequestDeviceError
impl Display for ColorStateError
impl Display for CreateComputePipelineError
impl Display for CreateRenderPipelineError
impl Display for CreateShaderModuleError
impl Display for DepthStencilStateError
impl Display for ImplicitLayoutError
impl Display for ConfigureSurfaceError
impl Display for wgpu_core::present::SurfaceError
impl Display for BufferAccessError
impl Display for wgpu_core::resource::CreateBufferError
impl Display for CreateQuerySetError
impl Display for CreateSamplerError
impl Display for CreateTextureError
impl Display for CreateTextureViewError
impl Display for DestroyError
impl Display for TextureDimensionError
impl Display for TextureViewDestroyError
impl Display for TextureViewNotRenderableReason
impl Display for BindingError
impl Display for FilteringError
impl Display for InputError
impl Display for StageError
impl Display for wgpu_hal::DeviceError
impl Display for PipelineError
impl Display for wgpu_hal::ShaderError
impl Display for wgpu_hal::SurfaceError
impl Display for EventLoopError
impl Display for ExternalError
impl Display for BadIcon
impl Display for XNotSupported
impl Display for ConnectionError
impl Display for LibxcbLoadError
impl Display for ReplyError
impl Display for ReplyOrIdError
impl Display for x11rb_protocol::errors::ConnectError
impl Display for DisplayParsingError
impl Display for x11rb_protocol::errors::ParseError
impl Display for AssetLoadError
impl Display for DeserializeMetaError
impl Display for ParseAssetPathError
impl Display for ReadAssetBytesError
impl Display for UntypedAssetConversionError
impl Display for UntypedAssetId
impl Display for UntypedAssetIdConversionError
impl Display for AssetReaderError
impl Display for AssetWriterError
impl Display for InitializeError
impl Display for LogEntryError
impl Display for ProcessError
impl Display for ReadLogError
impl Display for ValidateLogError
impl Display for IdentifierError
impl Display for QueryComponentError
impl Display for QueryEntityError
impl Display for QuerySingleError
impl Display for ScheduleBuildError
impl Display for GltfError
impl Display for AxisSettingsError
impl Display for ButtonSettingsError
impl Display for InvalidDirectionError
impl Display for Access<'_>
impl Display for ReflectKind
impl Display for HexColorError
impl Display for GenerateTangentsError
impl Display for IcosphereError
impl Display for MorphBuildError
impl Display for InputSlotError
impl Display for NodeRunError
impl Display for OutputSlotError
impl Display for RenderGraphError
impl Display for RunSubGraphError
impl Display for SlotType
impl Display for bevy_internal::render::render_resource::encase::internal::Error
impl Display for AsBindGroupError
impl Display for PipelineCacheError
impl Display for ShaderLoaderError
impl Display for ShaderReflectError
impl Display for SpecializedMeshPipelineError
impl Display for RenderGraphRunnerError
impl Display for HdrTextureLoaderError
impl Display for ImageLoaderError
impl Display for TextureError
impl Display for SceneLoaderError
impl Display for SceneSpawnError
impl Display for bevy_internal::scene::ron::Error
impl Display for TextureAtlasBuilderError
impl Display for bevy_internal::tasks::futures_lite::io::ErrorKind
impl Display for FontLoaderError
impl Display for TextError
impl Display for ComputeGlobalTransformError
impl Display for GridPlacementError
impl Display for bevy_internal::ui::LayoutError
impl Display for ValArithmeticError
impl Display for CollectionAllocErr
impl Display for AsciiChar
impl Display for Infallible
impl Display for IpAddr
impl Display for SocketAddr
impl Display for VarError
impl Display for std::sync::mpsc::RecvTimeoutError
impl Display for std::sync::mpsc::TryRecvError
impl Display for bool
impl Display for char
impl Display for f32
impl Display for f64
impl Display for i8
impl Display for i16
impl Display for i32
impl Display for i64
impl Display for i128
impl Display for isize
impl Display for !
impl Display for str
impl Display for u8
impl Display for u16
impl Display for u32
impl Display for u64
impl Display for u128
impl Display for usize
impl Display for InvalidFont
impl Display for aho_corasick::util::error::BuildError
impl Display for aho_corasick::util::error::MatchError
impl Display for aho_corasick::util::primitives::PatternIDError
impl Display for aho_corasick::util::primitives::StateIDError
impl Display for allocator_api2::stable::alloc::AllocError
impl Display for Chmap
impl Display for alsa::error::Error
impl Display for Output
impl Display for Result
impl Display for async_channel::RecvError
impl Display for bitflags::parser::ParseError
impl Display for Hash
impl Display for HexError
impl Display for ChannelError
impl Display for PingError
impl Display for BackendSpecificError
impl Display for crossbeam_channel::err::RecvError
impl Display for SelectTimeoutError
impl Display for TrySelectError
impl Display for cursor_icon::ParseError
impl Display for data_encoding::DecodeError
impl Display for SpecificationError
impl Display for FixedBitSet
impl Display for CompressError
impl Display for flate2::mem::DecompressError
impl Display for getrandom::error::Error
impl Display for Code
impl Display for GamepadId
impl Display for EvCode
impl Display for Void
impl Display for gltf_json::path::Path
impl Display for ParseHexfError
impl Display for image::error::DecodingError
impl Display for image::error::EncodingError
impl Display for LimitError
impl Display for image::error::ParameterError
impl Display for UnsupportedError
impl Display for indexmap::TryReserveError
impl Display for log::kv::error::Error
impl Display for log::ParseLevelError
impl Display for SetLoggerError
impl Display for miniz_oxide::inflate::DecompressError
impl Display for naga::front::wgsl::error::ParseError
impl Display for Alignment
impl Display for naga::proc::layouter::LayoutError
impl Display for ComposerError
impl Display for nix::sys::time::TimeSpec
impl Display for nix::sys::time::TimeSpec
impl Display for nix::sys::time::TimeVal
impl Display for nix::sys::time::TimeVal
impl Display for Pid
impl Display for Infix
impl Display for Prefix
impl Display for Suffix
impl Display for num_traits::ParseFloatError
impl Display for png::common::ParameterError
impl Display for regex::regex::bytes::Regex
impl Display for regex::regex::string::Regex
impl Display for regex_automata::dfa::onepass::BuildError
impl Display for regex_automata::error::Error
impl Display for regex_automata::hybrid::error::BuildError
impl Display for CacheError
impl Display for regex_automata::meta::error::BuildError
impl Display for regex_automata::nfa::thompson::error::BuildError
impl Display for GroupInfoError
impl Display for UnicodeWordBoundaryError
impl Display for regex_automata::util::primitives::PatternIDError
impl Display for SmallIndexError
impl Display for regex_automata::util::primitives::StateIDError
impl Display for regex_automata::util::search::MatchError
impl Display for PatternSetInsertError
impl Display for DeserializeError
impl Display for SerializeError
impl Display for regex_syntax::ast::Error
impl Display for regex_syntax::ast::Error
impl Display for regex_syntax::hir::Error
impl Display for regex_syntax::hir::Error
impl Display for regex_syntax::hir::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 Display for regex_syntax::hir::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 Display for regex_syntax::unicode::CaseFoldError
impl Display for regex_syntax::unicode::CaseFoldError
impl Display for regex_syntax::unicode::UnicodeWordError
impl Display for regex_syntax::unicode::UnicodeWordError
impl Display for rustix::backend::io::errno::Errno
impl Display for Sequence
impl Display for serde::de::value::Error
impl Display for serde_json::error::Error
impl Display for Number
impl Display for RawValue
impl Display for Mode
impl Display for SeatInfo
impl Display for UnknownLayer
impl Display for SmolStr
impl Display for FiniteF32
impl Display for FiniteF64
impl Display for NonZeroPositiveF32
impl Display for NonZeroPositiveF64
impl Display for NormalizedF32
impl Display for NormalizedF64
impl Display for PositiveF32
impl Display for PositiveF64
impl Display for BeginSvg
impl Display for Circle
impl Display for Color
impl Display for Comment
impl Display for EndSvg
impl Display for Indentation
impl Display for LineSegment
impl Display for svg_fmt::svg::Path
impl Display for Polygon
impl Display for Rectangle
impl Display for Style
impl Display for Text
impl Display for ColorChoiceParseError
impl Display for ParseColorError
impl Display for tinyvec::arrayvec::TryFromSliceError
impl Display for Tag
impl Display for uuid::error::Error
impl Display for Braced
impl Display for Hyphenated
impl Display for Simple
impl Display for Urn
impl Display for value_bag::error::Error
impl Display for Interface
impl Display for ProtocolError
impl Display for WEnumError
impl Display for wayland_backend::rs::client::ObjectId
impl Display for wayland_backend::rs::server::ObjectId
impl Display for wayland_backend::sys::client::ObjectId
impl Display for wayland_backend::types::client::InvalidId
impl Display for NoWaylandLib
impl Display for wayland_backend::types::server::InvalidId
impl Display for CreateSurfaceError
impl Display for wgpu::RequestDeviceError
impl Display for BindingTypeMaxCountError
impl Display for LateMinBufferBindingSizeMismatch
impl Display for RenderBundleError
impl Display for ComputePassError
impl Display for RenderPassError
impl Display for InvalidQueue
impl Display for InvalidDevice
impl Display for MissingDownlevelFlags
impl Display for MissingFeatures
impl Display for ContextError
impl Display for FailedLimit
impl Display for InvalidAdapter
impl Display for wgpu_core::pipeline::ShaderError<ParseError>
impl Display for wgpu_core::pipeline::ShaderError<WithSpan<ValidationError>>
impl Display for InterfaceVar
impl Display for MissingBufferUsageError
impl Display for MissingTextureUsageError
impl Display for NumericType
impl Display for InstanceError
impl Display for NotSupportedError
impl Display for OsError
impl Display for VideoMode
impl Display for OpenError
impl Display for IdsExhausted
impl Display for Image
impl Display for MissingAssetSourceError
impl Display for MissingAssetWriterError
impl Display for MissingProcessedAssetReaderError
impl Display for MissingProcessedAssetWriterError
impl Display for WriteLogError
impl Display for InvalidGenerationError
impl Display for LoadDirectError
impl Display for MissingAssetLoaderForExtensionError
impl Display for MissingAssetLoaderForTypeIdError
impl Display for MissingAssetLoaderForTypeNameError
impl Display for Name
impl Display for DiagnosticPath
impl Display for ScheduleNotInitialized
impl Display for TryRunScheduleError
impl Display for BadName
impl Display for Directive
impl Display for FromEnvError
impl Display for bevy_internal::log::tracing_subscriber::filter::ParseError
impl Display for Targets
impl Display for bevy_internal::log::tracing_subscriber::reload::Error
impl Display for EnvFilter
impl Display for TryInitError
impl Display for BVec2
impl Display for BVec3
impl Display for BVec4
impl Display for Mat2
impl Display for Mat3
impl Display for Mat4
impl Display for Quat
impl Display for Vec2
impl Display for Vec3
impl Display for Vec4
impl Display for IVec2
impl Display for IVec3
impl Display for IVec4
impl Display for Affine2
impl Display for Affine3A
impl Display for BVec3A
impl Display for BVec4A
impl Display for DAffine2
impl Display for DAffine3
impl Display for DMat2
impl Display for DMat3
impl Display for DMat4
impl Display for DQuat
impl Display for DVec2
impl Display for DVec3
impl Display for DVec4
impl Display for I16Vec2
impl Display for I16Vec3
impl Display for I16Vec4
impl Display for I64Vec2
impl Display for I64Vec3
impl Display for I64Vec4
impl Display for Mat3A
impl Display for U16Vec2
impl Display for U16Vec3
impl Display for U16Vec4
impl Display for U64Vec2
impl Display for U64Vec3
impl Display for U64Vec4
impl Display for Vec3A
impl Display for UVec2
impl Display for UVec3
impl Display for UVec4
impl Display for bevy_internal::reflect::erased_serde::Error
impl Display for bevy_internal::reflect::AccessError<'_>
impl Display for ParsedPath
impl Display for MissingVertexAttributeError
impl Display for EnlargeError
impl Display for BufferAsyncError
impl Display for FileTextureError
impl Display for ScreenshotAlreadyRequestedError
impl Display for Position
impl Display for SpannedError
impl Display for bevy_internal::tasks::futures_lite::io::Error
impl Display for NonMaxI8
impl Display for NonMaxI16
impl Display for NonMaxI32
impl Display for NonMaxI64
impl Display for NonMaxI128
impl Display for NonMaxIsize
impl Display for NonMaxU8
impl Display for NonMaxU16
impl Display for NonMaxU32
impl Display for NonMaxU64
impl Display for NonMaxU128
impl Display for NonMaxUsize
impl Display for bevy_internal::utils::nonmax::ParseIntError
impl Display for bevy_internal::utils::nonmax::TryFromIntError
impl Display for SystemTimeError
impl Display for TryFromFloatSecsError
impl Display for Uuid
impl Display for Field
impl Display for FieldSet
impl Display for bevy_internal::utils::tracing::metadata::LevelFilter
impl Display for bevy_internal::utils::tracing::metadata::ParseLevelError
impl Display for ParseLevelFilterError
impl Display for bevy_internal::utils::tracing::Level
impl Display for SetGlobalDefaultError
impl Display for bevy_internal::utils::smallvec::alloc::alloc::AllocError
impl Display for bevy_internal::utils::smallvec::alloc::alloc::LayoutError
impl Display for bevy_internal::utils::smallvec::alloc::collections::TryReserveError
impl Display for FromVecWithNulError
impl Display for IntoStringError
impl Display for NulError
impl Display for ParseBoolError
impl Display for Utf8Error
impl Display for FromUtf8Error
impl Display for FromUtf16Error
impl Display for String
impl Display for core::array::TryFromSliceError
impl Display for core::ascii::EscapeDefault
impl Display for BorrowError
impl Display for BorrowMutError
impl Display for CharTryFromError
impl Display for ParseCharError
impl Display for DecodeUtf16Error
impl Display for core::char::EscapeDebug
impl Display for core::char::EscapeDefault
impl Display for core::char::EscapeUnicode
impl Display for ToLowercase
impl Display for ToUppercase
impl Display for TryFromCharError
impl Display for FromBytesUntilNulError
impl Display for FromBytesWithNulError
impl Display for Ipv4Addr
impl Display for Ipv6Addr
Write an Ipv6Addr, conforming to the canonical style described by RFC 5952.