pub fn sum<T>(collection: &[T]) -> TExpand description
Calculates the sum of all elements in a collection.
Works with any numeric type that implements std::ops::Add and can be copied.
§Arguments
collection- A slice of numeric values.
§Returns
T- The sum of all elements in the collection.
§Examples
use lowdash::sum;
// Integer sum
assert_eq!(sum(&[1, 2, 3, 4, 5]), 15);
// Float sum
assert_eq!(sum(&[1.1, 2.2, 3.3]), 6.6);