Trait SliceDifferentiate

Source
pub trait SliceDifferentiate<T>: Slice<Item = T> {
    // Required method
    const fn differentiate(&mut self)
       where T: SubAssign<T> + Copy;
}

Required Methods§

Source

const fn differentiate(&mut self)
where T: SubAssign<T> + Copy,

Differentiates the slice in-place.

Each value will be subtracted by the previous value.

It’s assumed that the first value of the slice is preceded by zeros.

§Example
use slice_ops::ops::*;
 
let mut x = [1, 5, 5, 6, 2, -1, 0, 0, 0];
 
x.differentiate();
 
assert_eq!(x, [1, 4, 0, 1, -4, -3, 1, 0, 0]);
 
x.integrate();
 
assert_eq!(x, [1, 5, 5, 6, 2, -1, 0, 0, 0]);

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.

Implementations on Foreign Types§

Source§

impl<T> SliceDifferentiate<T> for [T]

Source§

fn differentiate(&mut self)
where T: SubAssign<T> + Copy,

Implementors§