Struct gba::Align4

source ·
#[repr(C, align(4))]
pub struct Align4<T>(pub T);
Expand description

Wraps a value to be aligned to a minimum of 4.

If the size of the value held is already a multiple of 4 then this will be the same size as the wrapped value. Otherwise the compiler will add sufficient padding bytes on the end to make the size a multiple of 4.

Tuple Fields§

§0: T

Implementations§

source§

impl<const N: usize> Align4<[u8; N]>

source

pub fn as_u32_slice(&self) -> &[u32]

Views these bytes as a slice of u32

§Panics
  • If the number of bytes isn’t a multiple of 4
source

pub fn as_u16_slice(&self) -> &[u16]

Views these bytes as a slice of u16

§Panics
  • If the number of bytes isn’t a multiple of 2

Trait Implementations§

source§

impl<T: Debug> Debug for Align4<T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Align4<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Align4<T>
where T: RefUnwindSafe,

§

impl<T> Send for Align4<T>
where T: Send,

§

impl<T> Sync for Align4<T>
where T: Sync,

§

impl<T> Unpin for Align4<T>
where T: Unpin,

§

impl<T> UnwindSafe for Align4<T>
where T: UnwindSafe,

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