Enum midenc_hir_type::TypeRepr

source ·
pub enum TypeRepr {
    Default,
    Align(NonZeroU16),
    Packed(NonZeroU16),
    Transparent,
}
Expand description

This represents metadata about how a structured type will be represented in memory

Variants§

§

Default

This corresponds to the C ABI representation for a given type

§

Align(NonZeroU16)

This modifies the default representation, by raising the minimum alignment.

The alignment must be a power of two, e.g. 32, and values from 1 to 2^16 are allowed.

The alignment must be greater than the default minimum alignment of the type or this representation has no effect.

§

Packed(NonZeroU16)

This modifies the default representation, by lowering the minimum alignment of a type, and in the case of structs, changes the alignments of the fields to be the smaller of the specified alignment and the default alignment. This has the effect of changing the layout of a struct.

Notably, Packed(1) will result in a struct that has no alignment requirement, and no padding between fields.

The alignment must be a power of two, e.g. 32, and values from 1 to 2^16 are allowed.

The alignment must be smaller than the default alignment, or this representation has no effect.

§

Transparent

This may only be used on structs with no more than one non-zero sized field, and indicates that the representation of that field should be used for the struct.

Implementations§

source§

impl TypeRepr

source

pub fn packed(align: u16) -> Self

source

pub fn align(align: u16) -> Self

source

pub fn is_transparent(&self) -> bool

Return true if this type representation is transparent

source

pub fn is_packed(&self) -> bool

Return true if this type representation is packed

source

pub fn min_alignment(&self) -> Option<usize>

Get the custom alignment given for this type representation, if applicable

Trait Implementations§

source§

impl Clone for TypeRepr

source§

fn clone(&self) -> TypeRepr

Returns a copy 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 Debug for TypeRepr

source§

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

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

impl Default for TypeRepr

source§

fn default() -> TypeRepr

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

impl Hash for TypeRepr

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 PartialEq for TypeRepr

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for TypeRepr

source§

impl Eq for TypeRepr

source§

impl StructuralPartialEq for TypeRepr

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: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.