pub struct StackReq { /* private fields */ }Expand description
Stack allocation requirements.
Implementations§
Source§impl StackReq
impl StackReq
Sourcepub 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.
§Errors
- if
alignis smaller than the minimum required alignment for an object of typeT. - if
alignis not a power of two. - if the size computation overflows
Sourcepub const fn new<T>(n: usize) -> StackReq
pub const fn new<T>(n: usize) -> StackReq
Allocation requirements sufficient for n elements of type T.
§Errors
- if the size computation overflows
Sourcepub const fn size_bytes(&self) -> usize
pub const fn size_bytes(&self) -> usize
The number of allocated bytes required, aligned to self.align_bytes().
Sourcepub const fn align_bytes(&self) -> usize
pub const fn align_bytes(&self) -> usize
The alignment of allocated bytes required, or 0 if the size overflowed.
Sourcepub 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, or usize::MAX in
the case of overflow.
§Panics
- if the size computation overflowed
Sourcepub const fn layout(self) -> Result<Layout, LayoutError>
pub const fn layout(self) -> Result<Layout, LayoutError>
Returns the corresponding layout for the allocation size and alignment.
Sourcepub 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.
Sourcepub const fn all_of(reqs: &[Self]) -> Self
pub const fn all_of(reqs: &[Self]) -> Self
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.
Sourcepub 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.
Sourcepub fn any_of(reqs: &[StackReq]) -> StackReq
pub fn any_of(reqs: &[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.
Sourcepub const fn array(self, n: usize) -> StackReq
pub const fn array(self, n: usize) -> StackReq
Same as StackReq::and repeated n times.