Trait bevy_internal::utils::smallvec::alloc::fmt::UpperHex

1.0.0 · source ·
pub trait UpperHex {
    // Required method
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description

X formatting.

The UpperHex trait should format its output as a number in hexadecimal, with A through F in upper case.

For primitive signed integers (i8 to i128, and isize), negative values are formatted as the two’s complement representation.

The alternate flag, #, adds a 0x in front of the output.

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

Examples

Basic usage with i32:

let x = 42; // 42 is '2A' in hex

assert_eq!(format!("{x:X}"), "2A");
assert_eq!(format!("{x:#X}"), "0x2A");

assert_eq!(format!("{:X}", -16), "FFFFFFF0");

Implementing UpperHex on a type:

use std::fmt;

struct Length(i32);

impl fmt::UpperHex for Length {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let val = self.0;

        fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation
    }
}

let l = Length(i32::MAX);

assert_eq!(format!("l as hex is: {l:X}"), "l as hex is: 7FFFFFFF");

assert_eq!(format!("l as hex is: {l:#010X}"), "l as hex is: 0x7FFFFFFF");

Required Methods§

source

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.

Implementors§

source§

impl UpperHex for i8

source§

impl UpperHex for i16

source§

impl UpperHex for i32

source§

impl UpperHex for i64

source§

impl UpperHex for i128

source§

impl UpperHex for isize

source§

impl UpperHex for u8

source§

impl UpperHex for u16

source§

impl UpperHex for u32

source§

impl UpperHex for u64

source§

impl UpperHex for u128

source§

impl UpperHex for usize

source§

impl UpperHex for alsa::poll::Flags

source§

impl UpperHex for PortCap

source§

impl UpperHex for PortType

source§

impl UpperHex for Remove

source§

impl UpperHex for UsageFlags

source§

impl UpperHex for AllocationFlags

source§

impl UpperHex for MemoryPropertyFlags

source§

impl UpperHex for DescriptorSetLayoutCreateFlags

source§

impl UpperHex for DescriptorPoolCreateFlags

source§

impl UpperHex for EventMask

source§

impl UpperHex for WatchMask

source§

impl UpperHex for ChannelTypeQualifiers

source§

impl UpperHex for DataFormatFlags

source§

impl UpperHex for naga::back::glsl::features::Features

source§

impl UpperHex for naga::back::glsl::WriterFlags

source§

impl UpperHex for ImageTypeFlags

source§

impl UpperHex for naga::back::spv::WriterFlags

source§

impl UpperHex for RayFlag

source§

impl UpperHex for naga::back::wgsl::writer::WriterFlags

source§

impl UpperHex for Barrier

source§

impl UpperHex for StorageAccess

source§

impl UpperHex for GlobalUse

source§

impl UpperHex for UniformityRequirements

source§

impl UpperHex for Capabilities

source§

impl UpperHex for naga::valid::ShaderStages

source§

impl UpperHex for ValidationFlags

source§

impl UpperHex for TypeFlags

source§

impl UpperHex for nix::fcntl::AtFlags

source§

impl UpperHex for nix::fcntl::FallocateFlags

source§

impl UpperHex for FdFlag

source§

impl UpperHex for OFlag

source§

impl UpperHex for nix::fcntl::RenameFlags

source§

impl UpperHex for SealFlag

source§

impl UpperHex for MntFlags

source§

impl UpperHex for MsFlags

source§

impl UpperHex for CloneFlags

source§

impl UpperHex for EpollCreateFlags

source§

impl UpperHex for EpollFlags

source§

impl UpperHex for EfdFlags

source§

impl UpperHex for MemFdCreateFlag

source§

impl UpperHex for SaFlags

source§

impl UpperHex for SfdFlags

source§

impl UpperHex for nix::sys::stat::Mode

source§

impl UpperHex for SFlag

source§

impl UpperHex for FsFlags

source§

impl UpperHex for WaitPidFlag

source§

impl UpperHex for AccessFlags

source§

impl UpperHex for Transformations

source§

impl UpperHex for rustix::backend::event::epoll::CreateFlags

source§

impl UpperHex for EventFlags

source§

impl UpperHex for PollFlags

source§

impl UpperHex for EventfdFlags

source§

impl UpperHex for rustix::backend::fs::inotify::CreateFlags

source§

impl UpperHex for WatchFlags

source§

impl UpperHex for Access

source§

impl UpperHex for rustix::backend::fs::types::AtFlags

source§

impl UpperHex for rustix::backend::fs::types::FallocateFlags

source§

impl UpperHex for MemfdFlags

source§

impl UpperHex for rustix::backend::fs::types::Mode

source§

impl UpperHex for OFlags

source§

impl UpperHex for rustix::backend::fs::types::RenameFlags

source§

impl UpperHex for ResolveFlags

source§

impl UpperHex for SealFlags

source§

impl UpperHex for StatVfsMountFlags

source§

impl UpperHex for StatxFlags

source§

impl UpperHex for DupFlags

source§

impl UpperHex for FdFlags

source§

impl UpperHex for ReadWriteFlags

source§

impl UpperHex for MountFlags

source§

impl UpperHex for MountPropagationFlags

source§

impl UpperHex for UnmountFlags

source§

impl UpperHex for RecvFlags

source§

impl UpperHex for SendFlags

source§

impl UpperHex for PipeFlags

source§

impl UpperHex for SpliceFlags

source§

impl UpperHex for ShmOFlags

source§

impl UpperHex for FutexFlags

source§

impl UpperHex for TimerfdFlags

source§

impl UpperHex for TimerfdTimerFlags

source§

impl UpperHex for IFlags

source§

impl UpperHex for XattrFlags

source§

impl UpperHex for SocketFlags

source§

impl UpperHex for SockaddrXdpFlags

source§

impl UpperHex for XdpDescOptions

source§

impl UpperHex for XdpOptionsFlags

source§

impl UpperHex for XdpRingFlags

source§

impl UpperHex for XdpUmemRegFlags

source§

impl UpperHex for MembarrierQuery

source§

impl UpperHex for PidfdFlags

source§

impl UpperHex for PidfdGetfdFlags

source§

impl UpperHex for FloatingPointEmulationControl

source§

impl UpperHex for FloatingPointExceptionMode

source§

impl UpperHex for SpeculationFeatureControl

source§

impl UpperHex for SpeculationFeatureState

source§

impl UpperHex for UnalignedAccessControl

source§

impl UpperHex for WaitOptions

source§

impl UpperHex for WaitidOptions

source§

impl UpperHex for CapabilityFlags

source§

impl UpperHex for CapabilitiesSecureBits

source§

impl UpperHex for TaggedAddressMode

source§

impl UpperHex for ThreadNameSpaceType

source§

impl UpperHex for UnshareFlags

source§

impl UpperHex for smithay_client_toolkit::shell::wlr_layer::Anchor

source§

impl UpperHex for CooperativeMatrixOperands

source§

impl UpperHex for FPFastMathMode

source§

impl UpperHex for FragmentShadingRate

source§

impl UpperHex for FunctionControl

source§

impl UpperHex for ImageOperands

source§

impl UpperHex for KernelProfilingInfo

source§

impl UpperHex for LoopControl

source§

impl UpperHex for MemoryAccess

source§

impl UpperHex for MemorySemantics

source§

impl UpperHex for RayFlags

source§

impl UpperHex for SelectionControl

source§

impl UpperHex for Braced

source§

impl UpperHex for Hyphenated

source§

impl UpperHex for Simple

source§

impl UpperHex for Urn

source§

impl UpperHex for DndAction

source§

impl UpperHex for wayland_client::protocol::wl_output::Mode

source§

impl UpperHex for wayland_client::protocol::wl_seat::Capability

source§

impl UpperHex for Resize

source§

impl UpperHex for Transient

source§

impl UpperHex for WindowManagerCapabilities

source§

impl UpperHex for WindowState

source§

impl UpperHex for wayland_protocols::wp::linux_dmabuf::zv1::generated::client::zwp_linux_buffer_params_v1::Flags

source§

impl UpperHex for TrancheFlags

source§

impl UpperHex for Kind

source§

impl UpperHex for wayland_protocols::wp::text_input::zv1::generated::client::zwp_text_input_v1::ContentHint

source§

impl UpperHex for wayland_protocols::wp::text_input::zv3::generated::client::zwp_text_input_v3::ContentHint

source§

impl UpperHex for ConstraintAdjustment

source§

impl UpperHex for wayland_protocols_plasma::output_device::v1::generated::client::org_kde_kwin_outputdevice::Capability

source§

impl UpperHex for wayland_protocols_plasma::output_device::v2::generated::client::kde_output_device_v2::Capability

source§

impl UpperHex for wayland_protocols_plasma::text_input::v2::generated::client::zwp_text_input_v2::ContentHint

source§

impl UpperHex for wayland_protocols_wlr::layer_shell::v1::generated::client::zwlr_layer_surface_v1::Anchor

source§

impl UpperHex for wayland_protocols_wlr::screencopy::v1::generated::client::zwlr_screencopy_frame_v1::Flags

source§

impl UpperHex for PipelineFlags

source§

impl UpperHex for AccelerationStructureUses

source§

impl UpperHex for AttachmentOps

source§

impl UpperHex for BindGroupLayoutFlags

source§

impl UpperHex for BufferUses

source§

impl UpperHex for FormatAspects

source§

impl UpperHex for MemoryFlags

source§

impl UpperHex for PipelineLayoutFlags

source§

impl UpperHex for TextureFormatCapabilities

source§

impl UpperHex for TextureUses

source§

impl UpperHex for Workarounds

source§

impl UpperHex for AccelerationStructureFlags

source§

impl UpperHex for AccelerationStructureGeometryFlags

source§

impl UpperHex for DownlevelFlags

source§

impl UpperHex for PipelineStatisticsTypes

source§

impl UpperHex for TextureFormatFeatureFlags

source§

impl UpperHex for ModifiersState

source§

impl UpperHex for WindowButtons

source§

impl UpperHex for xkb_state_component

source§

impl UpperHex for bevy_internal::pbr::MeshFlags

source§

impl UpperHex for MeshPipelineKey

source§

impl UpperHex for MeshPipelineViewLayoutKey

source§

impl UpperHex for StandardMaterialFlags

source§

impl UpperHex for RenderAssetUsages

source§

impl UpperHex for BufferUsages

source§

impl UpperHex for ColorWrites

source§

impl UpperHex for bevy_internal::render::render_resource::ShaderStages

source§

impl UpperHex for TextureUsages

source§

impl UpperHex for Backends

source§

impl UpperHex for InstanceFlags

source§

impl UpperHex for bevy_internal::render::settings::WgpuFeatures

source§

impl UpperHex for CompressedImageFormats

source§

impl UpperHex for Extensions

source§

impl UpperHex for ColorMaterialFlags

source§

impl UpperHex for Mesh2dPipelineKey

source§

impl UpperHex for bevy_internal::sprite::MeshFlags

source§

impl UpperHex for SpritePipelineKey

source§

impl UpperHex for NonMaxI8

source§

impl UpperHex for NonMaxI16

source§

impl UpperHex for NonMaxI32

source§

impl UpperHex for NonMaxI64

source§

impl UpperHex for NonMaxI128

source§

impl UpperHex for NonMaxIsize

source§

impl UpperHex for NonMaxU8

source§

impl UpperHex for NonMaxU16

source§

impl UpperHex for NonMaxU32

source§

impl UpperHex for NonMaxU64

source§

impl UpperHex for NonMaxU128

source§

impl UpperHex for NonMaxUsize

source§

impl UpperHex for Uuid

1.34.0 · source§

impl UpperHex for NonZeroI8

1.34.0 · source§

impl UpperHex for NonZeroI16

1.34.0 · source§

impl UpperHex for NonZeroI32

1.34.0 · source§

impl UpperHex for NonZeroI64

1.34.0 · source§

impl UpperHex for NonZeroI128

1.34.0 · source§

impl UpperHex for NonZeroIsize

1.28.0 · source§

impl UpperHex for NonZeroU8

1.28.0 · source§

impl UpperHex for NonZeroU16

1.28.0 · source§

impl UpperHex for NonZeroU32

1.28.0 · source§

impl UpperHex for NonZeroU64

1.28.0 · source§

impl UpperHex for NonZeroU128

1.28.0 · source§

impl UpperHex for NonZeroUsize

source§

impl<'s, T> UpperHex for SliceVec<'s, T>
where T: UpperHex,

source§

impl<A> UpperHex for TinyVec<A>
where A: Array, <A as Array>::Item: UpperHex,

source§

impl<A> UpperHex for ArrayVec<A>
where A: Array, <A as Array>::Item: UpperHex,

source§

impl<T> UpperHex for &T
where T: UpperHex + ?Sized,

source§

impl<T> UpperHex for &mut T
where T: UpperHex + ?Sized,

1.74.0 · source§

impl<T> UpperHex for Saturating<T>
where T: UpperHex,

1.11.0 · source§

impl<T> UpperHex for Wrapping<T>
where T: UpperHex,