BitElement

Struct BitElement 

Source
#[repr(transparent)]
#[doc(hidden)] pub struct BitElement<T = usize> { pub elem: T, }
Expand description

§Unified Element Constructor

This type is a hack around the fact that Cell and AtomicUN all have const fn new(val: Inner) -> Self; constructors, but the numberic fundamentals do not. As such, the standard library does not provide a unified construction syntax to turn an integer fundamental into the final type.

This provides a const fn BitElement::<_>::new(R) -> Self; function, implemented only for the BitStore implementors that the crate provides, that the constructor macros can use to turn integers into final values without using mem::transmute. While transmute is acceptable in this case (the types are all #[repr(transparent)]), it is still better avoided where possible.

As this is a macro assistant, it is publicly exposed, but is not public API. It has no purpose outside of the crate’s macros.

Fields§

§elem: T

Implementations§

Source§

impl BitElement<u8>

Source

pub const fn new(elem: u8) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<Cell<u8>>

Source

pub const fn new(elem: u8) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<AtomicU8>

Source

pub const fn new(elem: u8) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<u16>

Source

pub const fn new(elem: u16) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<Cell<u16>>

Source

pub const fn new(elem: u16) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<AtomicU16>

Source

pub const fn new(elem: u16) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<u32>

Source

pub const fn new(elem: u32) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<Cell<u32>>

Source

pub const fn new(elem: u32) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<AtomicU32>

Source

pub const fn new(elem: u32) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<u64>

Source

pub const fn new(elem: u64) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<Cell<u64>>

Source

pub const fn new(elem: u64) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<AtomicU64>

Source

pub const fn new(elem: u64) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<usize>

Source

pub const fn new(elem: usize) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<Cell<usize>>

Source

pub const fn new(elem: usize) -> Self

Creates a new element wrapper from a raw integer.

Source§

impl BitElement<AtomicUsize>

Source

pub const fn new(elem: usize) -> Self

Creates a new element wrapper from a raw integer.

Trait Implementations§

Source§

impl<T: Clone> Clone for BitElement<T>

Source§

fn clone(&self) -> BitElement<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for BitElement<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for BitElement<T>

Source§

fn default() -> BitElement<T>

Returns the “default value” for a type. Read more
Source§

impl<T: Eq> Eq for BitElement<T>

Source§

#[doc(hidden)] fn assert_receiver_is_total_eq(&self)

Source§

impl<T: Hash> Hash for BitElement<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Ord> Ord for BitElement<T>

Source§

fn cmp(&self, other: &BitElement<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for BitElement<T>

Source§

fn eq(&self, other: &BitElement<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for BitElement<T>

Source§

fn partial_cmp(&self, other: &BitElement<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
If self == other, returns ControlFlow::Continue(()). Otherwise, returns ControlFlow::Break(self < other). Read more
Source§

#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
Same as __chaining_lt, but for <= instead of <.
Source§

#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
Same as __chaining_lt, but for > instead of <.
Source§

#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
Same as __chaining_lt, but for >= instead of <.
Source§

impl<T: Copy> Copy for BitElement<T>

Source§

impl<T> StructuralPartialEq for BitElement<T>