Sum_Range
This crate provides a trait for efficiently calculating the sum of numbers within a range, including support for odd and even number sums.
Supported Range Types
RangeRangeInclusiveRangeToRangeToInclusive
Trait Methods
sum_range: Calculates the sum of all numbers in the range.sum_odd_range: Calculates the sum of all odd numbers in the range.sum_even_range: Calculates the sum of all even numbers in the range.
Note
- For
RangeToandRangeToInclusive, signed integer types are not supported.
Usage
use SumRange;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
License
This crate is licensed under the MIT license.