pub struct RelativeParams<T, E = T> {
pub zero_thresh: E,
pub max_relative: E,
/* private fields */
}
Expand description
A struct to use for approximate equality.
let test = RelativeParams::<f32>::new(Some(0.05), Some(0.001));
assert!(test.close_to(&1.0, &1.001));
assert!(test.close_to(&1001., &1000.));
assert!(test.close_to_zero(&-0.05));
assert!(! test.close_to(&0.1, &0.11));
assert!(! test.close_to_zero(&0.06));
Fields§
§zero_thresh: E
Below this threshold in absolute value, values are considered close to zero.
max_relative: E
Values not close to zero are considered close to each other if their relative error is at most this large.
Implementations§
Source§impl RelativeParams<f32, f32>
impl RelativeParams<f32, f32>
Source§impl RelativeParams<f64, f64>
impl RelativeParams<f64, f64>
Source§impl RelativeParams<Complex32, f32>
impl RelativeParams<Complex32, f32>
Source§impl RelativeParams<Complex64, f64>
impl RelativeParams<Complex64, f64>
Trait Implementations§
Source§impl<T: Clone, E: Clone> Clone for RelativeParams<T, E>
impl<T: Clone, E: Clone> Clone for RelativeParams<T, E>
Source§fn clone(&self) -> RelativeParams<T, E>
fn clone(&self) -> RelativeParams<T, E>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl CloseTo for RelativeParams<Complex32, f32>
impl CloseTo for RelativeParams<Complex32, f32>
Source§impl CloseTo for RelativeParams<Complex64, f64>
impl CloseTo for RelativeParams<Complex64, f64>
Source§impl CloseTo for RelativeParams<f32, f32>
impl CloseTo for RelativeParams<f32, f32>
Source§impl CloseTo for RelativeParams<f64, f64>
impl CloseTo for RelativeParams<f64, f64>
impl<T: Copy, E: Copy> Copy for RelativeParams<T, E>
impl<T: Eq, E: Eq> Eq for RelativeParams<T, E>
impl<T, E> StructuralPartialEq for RelativeParams<T, E>
Auto Trait Implementations§
impl<T, E> Freeze for RelativeParams<T, E>where
E: Freeze,
impl<T, E> RefUnwindSafe for RelativeParams<T, E>where
E: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, E> Send for RelativeParams<T, E>
impl<T, E> Sync for RelativeParams<T, E>
impl<T, E> Unpin for RelativeParams<T, E>
impl<T, E> UnwindSafe for RelativeParams<T, E>where
E: UnwindSafe,
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more