polars_ops/chunked_array/
sum.rs

1use arrow::types::NativeType;
2use num_traits::{NumCast, ToPrimitive};
3
4pub(super) fn sum_slice<T, S>(values: &[T]) -> S
5where
6    T: NativeType + ToPrimitive,
7    S: NumCast + std::iter::Sum,
8{
9    values
10        .iter()
11        .copied()
12        .map(|t| unsafe {
13            let s: S = NumCast::from(t).unwrap_unchecked();
14            s
15        })
16        .sum()
17}