[][src]Trait itemops::ops::ItemSum

pub trait ItemSum {
    type Item;
    fn sum_step(self, step: usize) -> Self::Item;
}

An item summing trait.

Associated Types

type Item

Loading content...

Required methods

fn sum_step(self, step: usize) -> Self::Item

Method for summing items with a specified step.

Loading content...

Implementations on Foreign Types

impl<'_, T> ItemSum for &'_ [T] where
    T: Default + AddAssign + Copy
[src]

type Item = T

fn sum_step(self, step: usize) -> Self::Item[src]

Sums elements of a slice with a specified step.

If a slice is empty or a step is equal to zero, returns the default value of the item type.

Panics

This method will panic if the computation overflows and debug assertions are enabled.

Examples

let v = vec![3, 7, 4, 2, 8, 5]; 
  
assert_eq!(v.sum_step(2), 15);  
assert_eq!(v.sum_step(3), 5);
Loading content...

Implementors

Loading content...