Sha256: 4d2b3619dac1500bee223e11db0b4a5f75b0fbde65094bab157597af71f6b72a

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

//! The `bitcast` and `bitflags_bits` macros.

#![allow(unused_macros)]

// Ensure that the source and destination types are both primitive integer
// types and the same size, and then bitcast.
macro_rules! bitcast {
    ($x:expr) => {{
        if false {
            // Ensure the source and destinations are primitive integer types.
            let _ = !$x;
            let _ = $x as u8;
            0
        } else if false {
            // Ensure that the source and destinations are the same size.
            // SAFETY: This code is under an `if false`.
            #[allow(
                unsafe_code,
                unused_unsafe,
                clippy::useless_transmute,
                clippy::missing_transmute_annotations
            )]
            unsafe {
                ::core::mem::transmute($x)
            }
        } else {
            // Do the conversion.
            $x as _
        }
    }};
}

/// Return a [`bitcast`] of the value of `$x.bits()`, where `$x` is a
/// `bitflags` type.
macro_rules! bitflags_bits {
    ($x:expr) => {{
        bitcast!($x.bits())
    }};
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/rustix-0.38.44/src/bitcast.rs
wasmtime-28.0.0 ./ext/cargo-vendor/rustix-0.38.43/src/bitcast.rs
wasmtime-27.0.0 ./ext/cargo-vendor/rustix-0.38.41/src/bitcast.rs
wasmtime-26.0.0 ./ext/cargo-vendor/rustix-0.38.37/src/bitcast.rs