Trait Alignable
pub trait Alignable {
// Required methods
fn align_offset(self, align: Self) -> Self;
fn align_up(self, align: Self) -> Self;
fn prev_power_of_two(self) -> Self;
}Expand description
This trait represents an alignable primitive integer value representing an address
Required Methods§
fn align_offset(self, align: Self) -> Self
fn align_offset(self, align: Self) -> Self
This function computes the offset, in bytes, needed to align self upwards so that
it is aligned to align bytes.
The following must be true, or this function will panic:
alignis non-zeroalignis a power of two
fn align_up(self, align: Self) -> Self
fn align_up(self, align: Self) -> Self
This function aligns self to the specified alignment (in bytes), aligning upwards.
The following must be true, or this function will panic:
alignis non-zeroalignis a power of twoself+alignmust be less thanSelf::MAX
fn prev_power_of_two(self) -> Self
fn prev_power_of_two(self) -> Self
Compute the nearest power of two less than or equal to self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.