pub trait UpperHex {
// Required method
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> ⓘ;
}
Expand description
core
X
formatting.
Re-exported from core
::fmt::
.
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 y = 42; // 42 is '2A' in hex
assert_eq!(format!("{y:X}"), "2A");
assert_eq!(format!("{y:#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§
1.0.0 · Sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> ⓘ
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> ⓘ
Formats the value using the given formatter.
§Errors
This function should return Err
if, and only if, the provided Formatter
returns Err
.
String formatting is considered an infallible operation; this function only
returns a Result
because writing to the underlying stream might fail and it must
provide a way to propagate the fact that an error has occurred back up the stack.
Implementors§
impl UpperHex for i8
impl UpperHex for i16
impl UpperHex for i32
impl UpperHex for i64
impl UpperHex for i128
impl UpperHex for isize
impl UpperHex for u8
impl UpperHex for u16
impl UpperHex for u32
impl UpperHex for u64
impl UpperHex for u128
impl UpperHex for usize
impl UpperHex for KeyEventState
impl UpperHex for KeyModifiers
impl UpperHex for KeyboardEnhancementFlags
impl UpperHex for BigInt
impl UpperHex for NonZeroI16_be
impl UpperHex for NonZeroI16_le
impl UpperHex for NonZeroI32_be
impl UpperHex for NonZeroI32_le
impl UpperHex for NonZeroI64_be
impl UpperHex for NonZeroI64_le
impl UpperHex for NonZeroI128_be
impl UpperHex for NonZeroI128_le
impl UpperHex for NonZeroU16_be
impl UpperHex for NonZeroU16_le
impl UpperHex for NonZeroU32_be
impl UpperHex for NonZeroU32_le
impl UpperHex for NonZeroU64_be
impl UpperHex for NonZeroU64_le
impl UpperHex for NonZeroU128_be
impl UpperHex for NonZeroU128_le
impl UpperHex for i16_be
impl UpperHex for i16_le
impl UpperHex for i32_be
impl UpperHex for i32_le
impl UpperHex for i64_be
impl UpperHex for i64_le
impl UpperHex for i128_be
impl UpperHex for i128_le
impl UpperHex for u16_be
impl UpperHex for u16_le
impl UpperHex for u32_be
impl UpperHex for u32_le
impl UpperHex for u64_be
impl UpperHex for u64_le
impl UpperHex for u128_be
impl UpperHex for u128_le
impl UpperHex for NonZeroI16_ube
impl UpperHex for NonZeroI16_ule
impl UpperHex for NonZeroI32_ube
impl UpperHex for NonZeroI32_ule
impl UpperHex for NonZeroI64_ube
impl UpperHex for NonZeroI64_ule
impl UpperHex for NonZeroI128_ube
impl UpperHex for NonZeroI128_ule
impl UpperHex for NonZeroU16_ube
impl UpperHex for NonZeroU16_ule
impl UpperHex for NonZeroU32_ube
impl UpperHex for NonZeroU32_ule
impl UpperHex for NonZeroU64_ube
impl UpperHex for NonZeroU64_ule
impl UpperHex for NonZeroU128_ube
impl UpperHex for NonZeroU128_ule
impl UpperHex for i16_ube
impl UpperHex for i16_ule
impl UpperHex for i32_ube
impl UpperHex for i32_ule
impl UpperHex for i64_ube
impl UpperHex for i64_ule
impl UpperHex for i128_ube
impl UpperHex for i128_ule
impl UpperHex for u16_ube
impl UpperHex for u16_ule
impl UpperHex for u32_ube
impl UpperHex for u32_ule
impl UpperHex for u64_ube
impl UpperHex for u64_ule
impl UpperHex for u128_ube
impl UpperHex for u128_ule
impl UpperHex for devela::_dep::rustix::event::epoll::CreateFlags
impl UpperHex for EventfdFlags
impl UpperHex for PollFlags
impl UpperHex for devela::_dep::rustix::fs::inotify::CreateFlags
impl UpperHex for ReadFlags
impl UpperHex for WatchFlags
impl UpperHex for Access
impl UpperHex for AtFlags
impl UpperHex for FallocateFlags
impl UpperHex for FdFlags
impl UpperHex for IFlags
impl UpperHex for MemfdFlags
impl UpperHex for Mode
impl UpperHex for MountFlags
impl UpperHex for MountPropagationFlags
impl UpperHex for OFlags
impl UpperHex for RenameFlags
impl UpperHex for ResolveFlags
impl UpperHex for SealFlags
impl UpperHex for StatVfsMountFlags
impl UpperHex for StatxFlags
impl UpperHex for UnmountFlags
impl UpperHex for XattrFlags
impl UpperHex for DupFlags
impl UpperHex for ReadWriteFlags
impl UpperHex for EventFlags
impl UpperHex for IoringAcceptFlags
impl UpperHex for IoringAsyncCancelFlags
impl UpperHex for IoringCqFlags
impl UpperHex for IoringCqeFlags
impl UpperHex for IoringEnterFlags
impl UpperHex for IoringFeatureFlags
impl UpperHex for IoringFsyncFlags
impl UpperHex for IoringMsgringFlags
impl UpperHex for IoringOpFlags
impl UpperHex for IoringPollFlags
impl UpperHex for IoringRecvFlags
impl UpperHex for IoringRegisterFlags
impl UpperHex for IoringRsrcFlags
impl UpperHex for IoringSendFlags
impl UpperHex for IoringSetupFlags
impl UpperHex for IoringSqFlags
impl UpperHex for IoringSqeFlags
impl UpperHex for IoringTimeoutFlags
impl UpperHex for RecvFlags
impl UpperHex for RecvmsgOutFlags
impl UpperHex for SendFlags
impl UpperHex for SocketFlags
impl UpperHex for devela::_dep::rustix::io_uring::SpliceFlags
impl UpperHex for MapFlags
impl UpperHex for MlockAllFlags
impl UpperHex for MlockFlags
impl UpperHex for MprotectFlags
impl UpperHex for MremapFlags
impl UpperHex for MsyncFlags
impl UpperHex for ProtFlags
impl UpperHex for UserfaultfdFlags
impl UpperHex for FsMountFlags
impl UpperHex for FsOpenFlags
impl UpperHex for FsPickFlags
impl UpperHex for MountAttrFlags
impl UpperHex for MoveMountFlags
impl UpperHex for OpenTreeFlags
impl UpperHex for SockaddrXdpFlags
impl UpperHex for XdpDescOptions
impl UpperHex for XdpOptionsFlags
impl UpperHex for XdpRingFlags
impl UpperHex for XdpUmemRegFlags
impl UpperHex for PipeFlags
impl UpperHex for devela::_dep::rustix::pipe::SpliceFlags
impl UpperHex for FloatingPointEmulationControl
impl UpperHex for FloatingPointExceptionMode
impl UpperHex for MembarrierQuery
impl UpperHex for PidfdFlags
impl UpperHex for PidfdGetfdFlags
impl UpperHex for SpeculationFeatureControl
impl UpperHex for SpeculationFeatureState
impl UpperHex for UnalignedAccessControl
impl UpperHex for WaitOptions
impl UpperHex for WaitidOptions
impl UpperHex for OpenptFlags
impl UpperHex for GetRandomFlags
impl UpperHex for ShmOFlags
impl UpperHex for ControlModes
impl UpperHex for InputModes
impl UpperHex for LocalModes
impl UpperHex for OutputModes
impl UpperHex for CapabilitiesSecureBits
impl UpperHex for CapabilityFlags
impl UpperHex for devela::_dep::rustix::thread::FutexFlags
impl UpperHex for TaggedAddressMode
impl UpperHex for ThreadNameSpaceType
impl UpperHex for TimerfdFlags
impl UpperHex for TimerfdTimerFlags
impl UpperHex for Channels
impl UpperHex for f32x4
impl UpperHex for f32x8
impl UpperHex for f64x2
impl UpperHex for f64x4
impl UpperHex for i8x16
impl UpperHex for i8x32
impl UpperHex for i16x8
impl UpperHex for i16x16
impl UpperHex for i32x4
impl UpperHex for i32x8
impl UpperHex for i64x2
impl UpperHex for i64x4
impl UpperHex for u8x16
impl UpperHex for u16x8
impl UpperHex for u16x16
impl UpperHex for u32x4
impl UpperHex for u32x8
impl UpperHex for u64x2
impl UpperHex for u64x4
impl UpperHex for devela::_dep::winnow::Bytes
impl UpperHex for ExampleBitfield
_bit_u8
and doc
only.impl UpperHex for ExampleBitfieldCustom
_bit_u8
and doc
only.impl UpperHex for ExampleBitfieldExtra
_bit_u8
and doc
only.impl UpperHex for ExampleEnumSet
doc
only.impl UpperHex for m128
impl UpperHex for m128d
impl UpperHex for m128i
impl UpperHex for m256
impl UpperHex for m256d
impl UpperHex for m256i
impl UpperHex for char7
impl UpperHex for char8
impl UpperHex for char16
impl UpperHex for Bytes
impl UpperHex for BytesMut
impl UpperHex for Flags
impl UpperHex for PortCap
impl UpperHex for PortType
impl UpperHex for Remove
impl<'t, T, F, U> UpperHex for OptionFmtOrElse<'t, T, F>
impl<'t, T, U> UpperHex for OptionFmtOr<'t, T, U>
impl<BUF: DstBuf, DST> UpperHex for DstValue<DST, BUF>
unsafe_layout
only.impl<T> UpperHex for &T
impl<T> UpperHex for &mut T
impl<T> UpperHex for NonZero<T>where
T: ZeroablePrimitive + UpperHex,
impl<T> UpperHex for OptionFmt<'_, T>where
T: UpperHex,
impl<T> UpperHex for Saturating<T>where
T: UpperHex,
impl<T> UpperHex for Wrapping<T>where
T: UpperHex,
impl<T: UpperHex> UpperHex for Bitwise<T>
impl<T: UpperHex> UpperHex for Frac<T>
impl<T: UpperHex> UpperHex for Int<T>
impl<const V: i8> UpperHex for devela::_info::examples::niche::NonValueI8<V>
doc
only.