pub trait TruncateTrait: Sized {
// Required method
fn truncate(&self, threshold: f64) -> Option<Self>;
}Expand description
Helper trait to allow truncation of values below threshold. Should eventually be ported to qoqo_calculator like this and be implemented for CalculatorFloat, CaclulatorComplex, f64 and Complexf64
Required Methods§
Sourcefn truncate(&self, threshold: f64) -> Option<Self>
fn truncate(&self, threshold: f64) -> Option<Self>
Truncates values mapping discarded values to None.
Values with an absolute value under the threshold are mapped to None. Values that are not removed are mapped to Some(value). For complex values the threshold is applied to real and imaginary part separately. All symbolic values are considered to be above the threshold.
§Arguments
threshold- The threshold for inclusion.
§Returns
Some(Self)- The truncated version of Self.None- Nothing was left in Self below the threshold.
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.