/// Chooses the fastest path for closure application.
/// Null values remain null.
///
/// # Example
///
/// ```
/// use polars::prelude::*;
/// fn double(ca: &UInt32Chunked) -> UInt32Chunked {
///     ca.apply(|v| v * 2)
/// }
/// ```
Chooses the fastest path for closure application.
Null values remain null.
Chooses the fastest path for closure application . Null values remain null .
fn apply<F>(&'a self, f: F) -> Self
    where
        F: Fn(T::Native) -> T::Native + Copy,
    {
        if let Ok(slice) = self.cont_slice() {
            let new: Xob<ChunkedArray<T>> = slice.iter().copied().map(f).collect();
            new.into_inner()
        } else {
            let mut ca: ChunkedArray<T> = self
                .data_views()
                .iter()
                .copied()
                .zip(self.null_bits())
                .map(|(slice, (null_count, opt_buffer))| {
                    let vec: AlignedVec<_> = slice.iter().copied().map(f).collect();
                    (vec, (null_count, opt_buffer))
                })
                .collect();
            ca.rename(self.name());
            ca
        }
    }
fn apply < F > ( & ' a self , f : F ) -> Self where F : Fn ( T :: Native ) -> T :: Native + Copy , { if let Ok ( slice ) = self . cont_slice ( ) { let new : Xob < ChunkedArray < T > > = slice . iter ( ) . copied ( ) . map ( f ) . collect ( ) ; new . into_inner ( ) } else { let mut ca : ChunkedArray < T > = self . data_views ( ) . iter ( ) . copied ( ) . zip ( self . null_bits ( ) ) . map ( | ( slice , ( null_count , opt_buffer ) ) | { let vec : AlignedVec < _ > = slice . iter ( ) . copied ( ) . map ( f ) . collect ( ) ; ( vec , ( null_count , opt_buffer ) ) } ) . collect ( ) ; ca . rename ( self . name ( ) ) ; ca } }
Chooses the fastest path for closure application.
Chooses the fastest path for closure application .
&'a self
f
F
example
None