Skip to main content

cubecl_core/frontend/iter/traits/
accum.rs

1use crate::prelude::*;
2
3/// An iterator item that can be read as a number, so `sum` and `product` accept both `T` and `&T`
4/// like [`Sum`](core::iter::Sum) and [`Product`](core::iter::Product).
5pub trait IntoNumericExpand<S: Numeric> {
6    /// Read the item.
7    fn into_numeric_expand(self, scope: &Scope) -> NativeExpand<S>;
8}
9
10impl<S: Numeric> IntoNumericExpand<S> for NativeExpand<S> {
11    fn into_numeric_expand(self, _scope: &Scope) -> NativeExpand<S> {
12        self
13    }
14}
15
16impl<S: Numeric> IntoNumericExpand<S> for &NativeExpand<S> {
17    fn into_numeric_expand(self, scope: &Scope) -> NativeExpand<S> {
18        self.__expand_deref_method(scope)
19    }
20}