Sequence

Trait Sequence 

Source
pub trait Sequence<T>: Iterator<Item = T>
where T: ConstZero,
{ // Provided method fn sum_next_n(&mut self, n: usize) -> T { ... } }
Expand description

A trait for mathematical sequences that can be iterated over.

Provided Methods§

Source

fn sum_next_n(&mut self, n: usize) -> T

Sum the next n elements of the sequence.

Advances the iterator by n elements. If the iterator has fewer than n elements left, it sums as many as possible. This should be used instead of .take(n).sum() because some sequences have a more efficient implementation for summing elements.

§Arguments
  • n - The number of elements to sum.
§Returns
  • The sum of the next n elements in the sequence.

Implementors§