Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-ops/src/chunked_array/sum.rs
6939 views
1
use arrow::types::NativeType;
2
use num_traits::{NumCast, ToPrimitive};
3
4
pub(super) fn sum_slice<T, S>(values: &[T]) -> S
5
where
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
}
18
19