pub trait LowerHex {
// Required method
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> ⓘ;
}
Expand description
core
x
formatting.
Re-exported from core
::fmt::
.
x
formatting.
The LowerHex
trait should format its output as a number in hexadecimal, with a
through f
in lower 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 LowerHex
on a type:
use std::fmt;
struct Length(i32);
impl fmt::LowerHex for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = self.0;
fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation
}
}
let l = Length(9);
assert_eq!(format!("l as hex is: {l:x}"), "l as hex is: 9");
assert_eq!(format!("l as hex is: {l:#010x}"), "l as hex is: 0x00000009");
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 LowerHex for i8
impl LowerHex for i16
impl LowerHex for i32
impl LowerHex for i64
impl LowerHex for i128
impl LowerHex for isize
impl LowerHex for u8
impl LowerHex for u16
impl LowerHex for u32
impl LowerHex for u64
impl LowerHex for u128
impl LowerHex for usize
impl LowerHex for KeyEventState
impl LowerHex for KeyModifiers
impl LowerHex for KeyboardEnhancementFlags
impl LowerHex for BigInt
impl LowerHex for NonZeroI16_be
impl LowerHex for NonZeroI16_le
impl LowerHex for NonZeroI32_be
impl LowerHex for NonZeroI32_le
impl LowerHex for NonZeroI64_be
impl LowerHex for NonZeroI64_le
impl LowerHex for NonZeroI128_be
impl LowerHex for NonZeroI128_le
impl LowerHex for NonZeroU16_be
impl LowerHex for NonZeroU16_le
impl LowerHex for NonZeroU32_be
impl LowerHex for NonZeroU32_le
impl LowerHex for NonZeroU64_be
impl LowerHex for NonZeroU64_le
impl LowerHex for NonZeroU128_be
impl LowerHex for NonZeroU128_le
impl LowerHex for i16_be
impl LowerHex for i16_le
impl LowerHex for i32_be
impl LowerHex for i32_le
impl LowerHex for i64_be
impl LowerHex for i64_le
impl LowerHex for i128_be
impl LowerHex for i128_le
impl LowerHex for u16_be
impl LowerHex for u16_le
impl LowerHex for u32_be
impl LowerHex for u32_le
impl LowerHex for u64_be
impl LowerHex for u64_le
impl LowerHex for u128_be
impl LowerHex for u128_le
impl LowerHex for NonZeroI16_ube
impl LowerHex for NonZeroI16_ule
impl LowerHex for NonZeroI32_ube
impl LowerHex for NonZeroI32_ule
impl LowerHex for NonZeroI64_ube
impl LowerHex for NonZeroI64_ule
impl LowerHex for NonZeroI128_ube
impl LowerHex for NonZeroI128_ule
impl LowerHex for NonZeroU16_ube
impl LowerHex for NonZeroU16_ule
impl LowerHex for NonZeroU32_ube
impl LowerHex for NonZeroU32_ule
impl LowerHex for NonZeroU64_ube
impl LowerHex for NonZeroU64_ule
impl LowerHex for NonZeroU128_ube
impl LowerHex for NonZeroU128_ule
impl LowerHex for i16_ube
impl LowerHex for i16_ule
impl LowerHex for i32_ube
impl LowerHex for i32_ule
impl LowerHex for i64_ube
impl LowerHex for i64_ule
impl LowerHex for i128_ube
impl LowerHex for i128_ule
impl LowerHex for u16_ube
impl LowerHex for u16_ule
impl LowerHex for u32_ube
impl LowerHex for u32_ule
impl LowerHex for u64_ube
impl LowerHex for u64_ule
impl LowerHex for u128_ube
impl LowerHex for u128_ule
impl LowerHex for devela::_dep::rustix::event::epoll::CreateFlags
impl LowerHex for EventfdFlags
impl LowerHex for PollFlags
impl LowerHex for devela::_dep::rustix::fs::inotify::CreateFlags
impl LowerHex for ReadFlags
impl LowerHex for WatchFlags
impl LowerHex for Access
impl LowerHex for AtFlags
impl LowerHex for FallocateFlags
impl LowerHex for FdFlags
impl LowerHex for IFlags
impl LowerHex for MemfdFlags
impl LowerHex for Mode
impl LowerHex for MountFlags
impl LowerHex for MountPropagationFlags
impl LowerHex for OFlags
impl LowerHex for RenameFlags
impl LowerHex for ResolveFlags
impl LowerHex for SealFlags
impl LowerHex for StatVfsMountFlags
impl LowerHex for StatxFlags
impl LowerHex for UnmountFlags
impl LowerHex for XattrFlags
impl LowerHex for DupFlags
impl LowerHex for ReadWriteFlags
impl LowerHex for EventFlags
impl LowerHex for IoringAcceptFlags
impl LowerHex for IoringAsyncCancelFlags
impl LowerHex for IoringCqFlags
impl LowerHex for IoringCqeFlags
impl LowerHex for IoringEnterFlags
impl LowerHex for IoringFeatureFlags
impl LowerHex for IoringFsyncFlags
impl LowerHex for IoringMsgringFlags
impl LowerHex for IoringOpFlags
impl LowerHex for IoringPollFlags
impl LowerHex for IoringRecvFlags
impl LowerHex for IoringRegisterFlags
impl LowerHex for IoringRsrcFlags
impl LowerHex for IoringSendFlags
impl LowerHex for IoringSetupFlags
impl LowerHex for IoringSqFlags
impl LowerHex for IoringSqeFlags
impl LowerHex for IoringTimeoutFlags
impl LowerHex for RecvFlags
impl LowerHex for RecvmsgOutFlags
impl LowerHex for SendFlags
impl LowerHex for SocketFlags
impl LowerHex for devela::_dep::rustix::io_uring::SpliceFlags
impl LowerHex for MapFlags
impl LowerHex for MlockAllFlags
impl LowerHex for MlockFlags
impl LowerHex for MprotectFlags
impl LowerHex for MremapFlags
impl LowerHex for MsyncFlags
impl LowerHex for ProtFlags
impl LowerHex for UserfaultfdFlags
impl LowerHex for FsMountFlags
impl LowerHex for FsOpenFlags
impl LowerHex for FsPickFlags
impl LowerHex for MountAttrFlags
impl LowerHex for MoveMountFlags
impl LowerHex for OpenTreeFlags
impl LowerHex for SockaddrXdpFlags
impl LowerHex for XdpDescOptions
impl LowerHex for XdpOptionsFlags
impl LowerHex for XdpRingFlags
impl LowerHex for XdpUmemRegFlags
impl LowerHex for PipeFlags
impl LowerHex for devela::_dep::rustix::pipe::SpliceFlags
impl LowerHex for FloatingPointEmulationControl
impl LowerHex for FloatingPointExceptionMode
impl LowerHex for MembarrierQuery
impl LowerHex for PidfdFlags
impl LowerHex for PidfdGetfdFlags
impl LowerHex for SpeculationFeatureControl
impl LowerHex for SpeculationFeatureState
impl LowerHex for UnalignedAccessControl
impl LowerHex for WaitOptions
impl LowerHex for WaitidOptions
impl LowerHex for OpenptFlags
impl LowerHex for GetRandomFlags
impl LowerHex for ShmOFlags
impl LowerHex for ControlModes
impl LowerHex for InputModes
impl LowerHex for LocalModes
impl LowerHex for OutputModes
impl LowerHex for CapabilitiesSecureBits
impl LowerHex for CapabilityFlags
impl LowerHex for devela::_dep::rustix::thread::FutexFlags
impl LowerHex for TaggedAddressMode
impl LowerHex for ThreadNameSpaceType
impl LowerHex for TimerfdFlags
impl LowerHex for TimerfdTimerFlags
impl LowerHex for Channels
impl LowerHex for f32x4
impl LowerHex for f32x8
impl LowerHex for f64x2
impl LowerHex for f64x4
impl LowerHex for i8x16
impl LowerHex for i8x32
impl LowerHex for i16x8
impl LowerHex for i16x16
impl LowerHex for i32x4
impl LowerHex for i32x8
impl LowerHex for i64x2
impl LowerHex for i64x4
impl LowerHex for u8x16
impl LowerHex for u16x8
impl LowerHex for u16x16
impl LowerHex for u32x4
impl LowerHex for u32x8
impl LowerHex for u64x2
impl LowerHex for u64x4
impl LowerHex for devela::_dep::winnow::Bytes
impl LowerHex for ExampleBitfield
_bit_u8
and doc
only.impl LowerHex for ExampleBitfieldCustom
_bit_u8
and doc
only.impl LowerHex for ExampleBitfieldExtra
_bit_u8
and doc
only.impl LowerHex for ExampleEnumSet
doc
only.impl LowerHex for m128
impl LowerHex for m128d
impl LowerHex for m128i
impl LowerHex for m256
impl LowerHex for m256d
impl LowerHex for m256i
impl LowerHex for char7
impl LowerHex for char8
impl LowerHex for char16
impl LowerHex for Bytes
impl LowerHex for BytesMut
impl LowerHex for Flags
impl LowerHex for PortCap
impl LowerHex for PortType
impl LowerHex for Remove
impl<'t, T, F, U> LowerHex for OptionFmtOrElse<'t, T, F>
impl<'t, T, U> LowerHex for OptionFmtOr<'t, T, U>
impl<BUF: DstBuf, DST> LowerHex for DstValue<DST, BUF>
unsafe_layout
only.impl<T> LowerHex for &T
impl<T> LowerHex for &mut T
impl<T> LowerHex for NonZero<T>where
T: ZeroablePrimitive + LowerHex,
impl<T> LowerHex for OptionFmt<'_, T>where
T: LowerHex,
impl<T> LowerHex for Saturating<T>where
T: LowerHex,
impl<T> LowerHex for Wrapping<T>where
T: LowerHex,
impl<T: LowerHex> LowerHex for Bitwise<T>
impl<T: LowerHex> LowerHex for Frac<T>
impl<T: LowerHex> LowerHex for Int<T>
impl<const V: i8> LowerHex for devela::_info::examples::niche::NonValueI8<V>
doc
only.