Skip to main content

BitFieldStyle

Enum BitFieldStyle 

Source
pub enum BitFieldStyle {
    Itanium,
    Microsoft,
}
Expand description

How a target allocates bit-fields into storage.

Everything else about laying a record out is one algorithm reading different sizes and alignments per target. This is not: the two answers below place the same members at different offsets and give the same struct different sizes, and no amount of changing what an int is turns one into the other. struct { unsigned m:3; char c; } is four bytes with the char at offset one under the first and eight bytes with it at offset four under the second.

Variants§

§

Itanium

The Itanium C++ ABI’s rule, which every psABI in this table except Windows follows. A bit-field goes at the next free bit unless that would make it span more storage than its own type occupies, in which case it starts at the next boundary of its alignment. Storage is shared between members of different types freely, so struct { char a:3; unsigned b:3; } is four bytes with both fields in the first one.

§

Microsoft

Microsoft’s rule, which both Windows environments follow and not only MSVC. A run of bit-fields is allocated into a unit the size and alignment of the declared type, and the unit is closed both when the next member’s declared type has a different size and when the field does not fit in what is left. An ordinary member closes a unit too, and the closed unit occupies its whole declared size whether or not the bits were used. So the same struct is eight bytes: a one byte unit for the char and a four byte one for the unsigned, aligned to four.

Implementations§

Source§

impl BitFieldStyle

Source

pub const fn as_str(self) -> &'static str

The name used in --print-config.

Trait Implementations§

Source§

impl Clone for BitFieldStyle

Source§

fn clone(&self) -> BitFieldStyle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for BitFieldStyle

Source§

impl Debug for BitFieldStyle

Source§

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

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

impl Eq for BitFieldStyle

Source§

impl PartialEq for BitFieldStyle

Source§

fn eq(&self, other: &BitFieldStyle) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BitFieldStyle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.