Trait bevy_internal::utils::smallvec::alloc::fmt::Binary

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

b formatting.

The Binary trait should format its output as a number in binary.

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

The alternate flag, #, adds a 0b 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 '101010' in binary

assert_eq!(format!("{x:b}"), "101010");
assert_eq!(format!("{x:#b}"), "0b101010");

assert_eq!(format!("{:b}", -16), "11111111111111111111111111110000");

Implementing Binary on a type:

use std::fmt;

struct Length(i32);

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

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

let l = Length(107);

assert_eq!(format!("l as binary is: {l:b}"), "l as binary is: 1101011");

assert_eq!(
    // Note that the `0b` prefix added by `#` is included in the total width, so we
    // need to add two to correctly display all 32 bits.
    format!("l as binary is: {l:#034b}"),
    "l as binary is: 0b00000000000000000000000001101011"
);

Required Methods§

source

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

Formats the value using the given formatter.

Implementors§

source§

impl Binary for i8

source§

impl Binary for i16

source§

impl Binary for i32

source§

impl Binary for i64

source§

impl Binary for i128

source§

impl Binary for isize

source§

impl Binary for u8

source§

impl Binary for u16

source§

impl Binary for u32

source§

impl Binary for u64

source§

impl Binary for u128

source§

impl Binary for usize

source§

impl Binary for alsa::poll::Flags

source§

impl Binary for PortCap

source§

impl Binary for PortType

source§

impl Binary for Remove

source§

impl Binary for FixedBitSet

source§

impl Binary for UsageFlags

source§

impl Binary for AllocationFlags

source§

impl Binary for MemoryPropertyFlags

source§

impl Binary for DescriptorSetLayoutCreateFlags

source§

impl Binary for DescriptorPoolCreateFlags

source§

impl Binary for EventMask

source§

impl Binary for WatchMask

source§

impl Binary for ChannelTypeQualifiers

source§

impl Binary for DataFormatFlags

source§

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

source§

impl Binary for naga::back::glsl::WriterFlags

source§

impl Binary for ImageTypeFlags

source§

impl Binary for naga::back::spv::WriterFlags

source§

impl Binary for RayFlag

source§

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

source§

impl Binary for Barrier

source§

impl Binary for StorageAccess

source§

impl Binary for GlobalUse

source§

impl Binary for UniformityRequirements

source§

impl Binary for Capabilities

source§

impl Binary for naga::valid::ShaderStages

source§

impl Binary for ValidationFlags

source§

impl Binary for TypeFlags

source§

impl Binary for nix::fcntl::AtFlags

source§

impl Binary for nix::fcntl::FallocateFlags

source§

impl Binary for FdFlag

source§

impl Binary for OFlag

source§

impl Binary for nix::fcntl::RenameFlags

source§

impl Binary for SealFlag

source§

impl Binary for MntFlags

source§

impl Binary for MsFlags

source§

impl Binary for CloneFlags

source§

impl Binary for EpollCreateFlags

source§

impl Binary for EpollFlags

source§

impl Binary for EfdFlags

source§

impl Binary for MemFdCreateFlag

source§

impl Binary for SaFlags

source§

impl Binary for SfdFlags

source§

impl Binary for nix::sys::stat::Mode

source§

impl Binary for SFlag

source§

impl Binary for FsFlags

source§

impl Binary for WaitPidFlag

source§

impl Binary for AccessFlags

source§

impl Binary for Transformations

source§

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

source§

impl Binary for EventFlags

source§

impl Binary for PollFlags

source§

impl Binary for EventfdFlags

source§

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

source§

impl Binary for WatchFlags

source§

impl Binary for Access

source§

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

source§

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

source§

impl Binary for MemfdFlags

source§

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

source§

impl Binary for OFlags

source§

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

source§

impl Binary for ResolveFlags

source§

impl Binary for SealFlags

source§

impl Binary for StatVfsMountFlags

source§

impl Binary for StatxFlags

source§

impl Binary for DupFlags

source§

impl Binary for FdFlags

source§

impl Binary for ReadWriteFlags

source§

impl Binary for MountFlags

source§

impl Binary for MountPropagationFlags

source§

impl Binary for UnmountFlags

source§

impl Binary for RecvFlags

source§

impl Binary for SendFlags

source§

impl Binary for PipeFlags

source§

impl Binary for SpliceFlags

source§

impl Binary for ShmOFlags

source§

impl Binary for FutexFlags

source§

impl Binary for TimerfdFlags

source§

impl Binary for TimerfdTimerFlags

source§

impl Binary for IFlags

source§

impl Binary for XattrFlags

source§

impl Binary for SocketFlags

source§

impl Binary for SockaddrXdpFlags

source§

impl Binary for XdpDescOptions

source§

impl Binary for XdpOptionsFlags

source§

impl Binary for XdpRingFlags

source§

impl Binary for XdpUmemRegFlags

source§

impl Binary for MembarrierQuery

source§

impl Binary for PidfdFlags

source§

impl Binary for PidfdGetfdFlags

source§

impl Binary for FloatingPointEmulationControl

source§

impl Binary for FloatingPointExceptionMode

source§

impl Binary for SpeculationFeatureControl

source§

impl Binary for SpeculationFeatureState

source§

impl Binary for UnalignedAccessControl

source§

impl Binary for WaitOptions

source§

impl Binary for WaitidOptions

source§

impl Binary for CapabilityFlags

source§

impl Binary for CapabilitiesSecureBits

source§

impl Binary for TaggedAddressMode

source§

impl Binary for ThreadNameSpaceType

source§

impl Binary for UnshareFlags

source§

impl Binary for smithay_client_toolkit::shell::wlr_layer::Anchor

source§

impl Binary for CooperativeMatrixOperands

source§

impl Binary for FPFastMathMode

source§

impl Binary for FragmentShadingRate

source§

impl Binary for FunctionControl

source§

impl Binary for ImageOperands

source§

impl Binary for KernelProfilingInfo

source§

impl Binary for LoopControl

source§

impl Binary for MemoryAccess

source§

impl Binary for MemorySemantics

source§

impl Binary for RayFlags

source§

impl Binary for SelectionControl

source§

impl Binary for DndAction

source§

impl Binary for wayland_client::protocol::wl_output::Mode

source§

impl Binary for wayland_client::protocol::wl_seat::Capability

source§

impl Binary for Resize

source§

impl Binary for Transient

source§

impl Binary for WindowManagerCapabilities

source§

impl Binary for WindowState

source§

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

source§

impl Binary for TrancheFlags

source§

impl Binary for Kind

source§

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

source§

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

source§

impl Binary for ConstraintAdjustment

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Binary for PipelineFlags

source§

impl Binary for AccelerationStructureUses

source§

impl Binary for AttachmentOps

source§

impl Binary for BindGroupLayoutFlags

source§

impl Binary for BufferUses

source§

impl Binary for FormatAspects

source§

impl Binary for MemoryFlags

source§

impl Binary for PipelineLayoutFlags

source§

impl Binary for TextureFormatCapabilities

source§

impl Binary for TextureUses

source§

impl Binary for Workarounds

source§

impl Binary for AccelerationStructureFlags

source§

impl Binary for AccelerationStructureGeometryFlags

source§

impl Binary for DownlevelFlags

source§

impl Binary for PipelineStatisticsTypes

source§

impl Binary for TextureFormatFeatureFlags

source§

impl Binary for ModifiersState

source§

impl Binary for WindowButtons

source§

impl Binary for xkb_state_component

source§

impl Binary for FilterId

source§

impl Binary for bevy_internal::pbr::MeshFlags

source§

impl Binary for MeshPipelineKey

source§

impl Binary for MeshPipelineViewLayoutKey

source§

impl Binary for StandardMaterialFlags

source§

impl Binary for RenderAssetUsages

source§

impl Binary for BufferUsages

source§

impl Binary for ColorWrites

source§

impl Binary for bevy_internal::render::render_resource::ShaderStages

source§

impl Binary for TextureUsages

source§

impl Binary for Backends

source§

impl Binary for InstanceFlags

source§

impl Binary for bevy_internal::render::settings::WgpuFeatures

source§

impl Binary for CompressedImageFormats

source§

impl Binary for Extensions

source§

impl Binary for ColorMaterialFlags

source§

impl Binary for Mesh2dPipelineKey

source§

impl Binary for bevy_internal::sprite::MeshFlags

source§

impl Binary for SpritePipelineKey

source§

impl Binary for NonMaxI8

source§

impl Binary for NonMaxI16

source§

impl Binary for NonMaxI32

source§

impl Binary for NonMaxI64

source§

impl Binary for NonMaxI128

source§

impl Binary for NonMaxIsize

source§

impl Binary for NonMaxU8

source§

impl Binary for NonMaxU16

source§

impl Binary for NonMaxU32

source§

impl Binary for NonMaxU64

source§

impl Binary for NonMaxU128

source§

impl Binary for NonMaxUsize

1.34.0 · source§

impl Binary for NonZeroI8

1.34.0 · source§

impl Binary for NonZeroI16

1.34.0 · source§

impl Binary for NonZeroI32

1.34.0 · source§

impl Binary for NonZeroI64

1.34.0 · source§

impl Binary for NonZeroI128

1.34.0 · source§

impl Binary for NonZeroIsize

1.28.0 · source§

impl Binary for NonZeroU8

1.28.0 · source§

impl Binary for NonZeroU16

1.28.0 · source§

impl Binary for NonZeroU32

1.28.0 · source§

impl Binary for NonZeroU64

1.28.0 · source§

impl Binary for NonZeroU128

1.28.0 · source§

impl Binary for NonZeroUsize

source§

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

source§

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

source§

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

source§

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

source§

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

1.74.0 · source§

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

1.11.0 · source§

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