#[non_exhaustive]pub enum OutputBound {
OneToOne,
AtMost {
max: usize,
},
Unbounded,
}Expand description
Upper bound on how many outputs an operation produces per input element.
Declared so a caller can size a destination buffer before the operation runs. That is what makes a scan-then-scatter implementation possible: with a per-element bound, exclusive-prefix-summing the per-element counts gives every worker a disjoint write offset, so no lock, no atomic counter, and no dynamically growing vector is needed on the hot path.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
OneToOne
Exactly one output per input. The output index equals the input index.
AtMost
At most max outputs per input element.
Unbounded
The output count cannot be bounded before running.
Callers must fall back to a growable collection. Kept representable and deliberately unpleasant so an operation that could declare a bound is not tempted to shrug.
Implementations§
Source§impl OutputBound
impl OutputBound
Sourcepub const fn upper_bound(self, elements: usize) -> Option<usize>
pub const fn upper_bound(self, elements: usize) -> Option<usize>
Worst-case total outputs for elements inputs, or None if unbounded
or the product would overflow.
Sourcepub const fn is_preallocatable(self, elements: usize) -> bool
pub const fn is_preallocatable(self, elements: usize) -> bool
Whether a caller can preallocate an exact destination for elements.
Sourcepub fn write_offsets(self, counts: &[usize]) -> Option<(Vec<usize>, usize)>
pub fn write_offsets(self, counts: &[usize]) -> Option<(Vec<usize>, usize)>
Exclusive prefix sum of counts, plus the total.
This is the scan that turns “how many outputs does each element make?”
into “where does each element write?”. Returns None if any count
exceeds this bound (a provider contract violation) or the total
overflows. Allocation is the caller’s single result buffer; the scan
itself is a running total with no per-element allocation.
Trait Implementations§
Source§impl Clone for OutputBound
impl Clone for OutputBound
Source§fn clone(&self) -> OutputBound
fn clone(&self) -> OutputBound
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputBound
impl Debug for OutputBound
Source§impl Hash for OutputBound
impl Hash for OutputBound
Source§impl PartialEq for OutputBound
impl PartialEq for OutputBound
impl Copy for OutputBound
impl Eq for OutputBound
impl StructuralPartialEq for OutputBound
Auto Trait Implementations§
impl Freeze for OutputBound
impl RefUnwindSafe for OutputBound
impl Send for OutputBound
impl Sync for OutputBound
impl Unpin for OutputBound
impl UnwindSafe for OutputBound
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§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