Struct StackReq
pub struct StackReq {
align: NonZero<usize>,
size: usize,
}
Expand description
Stack allocation requirements.
Fields§
§align: NonZero<usize>
§size: usize
Implementations§
§impl StackReq
impl StackReq
pub const fn new_aligned<T>(n: usize, align: usize) -> StackReq
pub const fn new_aligned<T>(n: usize, align: usize) -> StackReq
Allocation requirements sufficient for n
elements of type T
, overaligned with alignment
align
.
§Panics
- if
align
is smaller than the minimum required alignment for an object of typeT
. - if
align
is not a power of two. - if the size computation overflows
pub const fn new<T>(n: usize) -> StackReq
pub const fn new<T>(n: usize) -> StackReq
Allocation requirements sufficient for n
elements of type T
.
§Panics
- if the size computation overflows
pub const fn try_new_aligned<T>(
n: usize,
align: usize,
) -> Result<StackReq, SizeOverflow>
pub const fn try_new_aligned<T>( n: usize, align: usize, ) -> Result<StackReq, SizeOverflow>
Same as StackReq::new_aligned
, but returns an error in case the size computation
overflows.
§Panics
- if
align
is smaller than the minimum required alignment for an object of typeT
. - if
align
is not a power of two.
pub const fn try_new<T>(n: usize) -> Result<StackReq, SizeOverflow>
pub const fn try_new<T>(n: usize) -> Result<StackReq, SizeOverflow>
Same as StackReq::new
, but returns an error in case the size computation
overflows.
pub const fn size_bytes(&self) -> usize
pub const fn size_bytes(&self) -> usize
The number of allocated bytes required, aligned to self.align_bytes()
.
pub const fn align_bytes(&self) -> usize
pub const fn align_bytes(&self) -> usize
The alignment of allocated bytes required.
pub const fn unaligned_bytes_required(&self) -> usize
pub const fn unaligned_bytes_required(&self) -> usize
The number of allocated bytes required, with no alignment constraints.
§Panics
- if the size computation overflows
pub const fn try_unaligned_bytes_required(&self) -> Result<usize, SizeOverflow>
pub const fn try_unaligned_bytes_required(&self) -> Result<usize, SizeOverflow>
Same as StackReq::unaligned_bytes_required
, but returns an error if the size computation
overflows.
pub const fn and(self, other: StackReq) -> StackReq
pub const fn and(self, other: StackReq) -> StackReq
The required allocation to allocate storage sufficient for both of self
and other
,
simultaneously and in any order.
§Panics
- if the allocation requirement computation overflows.
pub fn all_of(reqs: impl IntoIterator<Item = StackReq>) -> StackReq
pub fn all_of(reqs: impl IntoIterator<Item = StackReq>) -> StackReq
The required allocation to allocate storage sufficient for all the requirements produced by the given iterator, simultaneously and in any order.
§Panics
- if the allocation requirement computation overflows.
pub const fn or(self, other: StackReq) -> StackReq
pub const fn or(self, other: StackReq) -> StackReq
The required allocation to allocate storage sufficient for either of self
and other
,
with only one being active at a time.
§Panics
- if the allocation requirement computation overflows.
pub fn any_of(reqs: impl IntoIterator<Item = StackReq>) -> StackReq
pub fn any_of(reqs: impl IntoIterator<Item = StackReq>) -> StackReq
The required allocation to allocate storage sufficient for any of the requirements produced by the given iterator, with at most one being active at a time.
§Panics
- if the allocation requirement computation overflows.
pub const fn try_and(self, other: StackReq) -> Result<StackReq, SizeOverflow>
pub const fn try_and(self, other: StackReq) -> Result<StackReq, SizeOverflow>
Same as StackReq::and
, but returns an error if the size computation overflows.
pub fn try_all_of(
reqs: impl IntoIterator<Item = StackReq>,
) -> Result<StackReq, SizeOverflow>
pub fn try_all_of( reqs: impl IntoIterator<Item = StackReq>, ) -> Result<StackReq, SizeOverflow>
Same as StackReq::all_of
, but returns an error if the size computation overflows.
pub const fn try_or(self, other: StackReq) -> Result<StackReq, SizeOverflow>
pub const fn try_or(self, other: StackReq) -> Result<StackReq, SizeOverflow>
Same as StackReq::or
, but returns an error if the size computation overflows.
pub fn try_any_of(
reqs: impl IntoIterator<Item = StackReq>,
) -> Result<StackReq, SizeOverflow>
pub fn try_any_of( reqs: impl IntoIterator<Item = StackReq>, ) -> Result<StackReq, SizeOverflow>
Same as StackReq::any_of
, but returns an error if the size computation overflows.
Trait Implementations§
impl Copy for StackReq
impl Eq for StackReq
impl StructuralPartialEq for StackReq
Auto Trait Implementations§
impl Freeze for StackReq
impl RefUnwindSafe for StackReq
impl Send for StackReq
impl Sync for StackReq
impl Unpin for StackReq
impl UnwindSafe for StackReq
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more