pub trait DeltaEncoderExt: Iterator where
    <Self as Iterator>::Item: Default + Copy + WrappingSub
{ fn deltas(self) -> DeltaEncoderIter<Self>Notable traits for DeltaEncoderIter<I>impl<I> Iterator for DeltaEncoderIter<I> where
    I: Iterator,
    <I as Iterator>::Item: WrappingSub + Copy
type Item = I::Item;

    where
        Self: Sized
, { ... } }

Provided Methods

Construct a delta-encoded iterator from an iterator. The first element of the iterator is used as the starting point for the delta-encoding. Note that unlike the [DeltaEncoder.encode] method, this method will panic if the delta is too large.

Example
use delta_encoding::DeltaEncoderExt;

// Consuming original data into a delta-encoded iterator.
let mut encoded: Vec<i64> = vec![1, 2, 5, 4, 2].into_iter().deltas().collect();
assert_eq!(encoded, vec![1, 1, 3, -1, -2]);

// Non-consuming original data, but avoiding the allocation of a new vector.
let mut encoded: Vec<i64> = vec![1, 2, 5, 4, 2].iter().copied().deltas().collect();
assert_eq!(encoded, vec![1, 1, 3, -1, -2]);

Implementors