pub trait MaskAware<T: Element, D: Dimension> {
// Required methods
fn data(&self) -> &Array<T, D>;
fn mask_opt(&self) -> Option<&Array<bool, D>>;
fn fill_value(&self) -> T
where T: Copy;
// Provided method
fn shape(&self) -> &[usize] { ... }
}Expand description
Shared view contract for functions that want to accept either an
Array or a MaskedArray (#505).
Implementations:
Array<T, D>:data()returnsself,mask_opt()returnsNone(no mask),fill_value()returnsT::zero(). The array is treated as fully unmasked.MaskedArray<T, D>: delegates to the existing accessors.
Downstream code that wants to write “one function, works on both”
should take &impl MaskAware<T, D> and consult mask_opt() to
decide whether to do mask propagation.
Required Methods§
Sourcefn mask_opt(&self) -> Option<&Array<bool, D>>
fn mask_opt(&self) -> Option<&Array<bool, D>>
Return the mask array if one is explicitly present, or None
when the input carries no mask (treated as fully unmasked).
For Array<T, D> this always returns None. For
MaskedArray<T, D> it returns Some when a real mask has
been explicitly set and None when the array is in the
nomask-sentinel state (#506).
Sourcefn fill_value(&self) -> Twhere
T: Copy,
fn fill_value(&self) -> Twhere
T: Copy,
Return the fill value to use for masked positions in derived results.