pub fn cast_bool_to_numeric<T>(array: &dyn Array, to: &DataType) -> Result<Box<dyn Array>>
where
    T: NativeType + num::One,
{
    let array = array.as_any().downcast_ref::<BooleanArray>().unwrap();

    let iter = array
        .iter()
        .map(|x| x.map(|x| if x { T::one() } else { T::default() }));

    // Soundness:
    //     The iterator is trustedLen
    let array = unsafe { Primitive::<T>::from_trusted_len_iter(iter) }.to(to.clone());

    Ok(Box::new(array))
}
/// Cast Boolean types to numeric
///
/// `false` returns 0 while `true` returns 1
Cast Boolean types to numeric
`false` returns 0 while `true` returns 1
Cast Boolean types to numeric ` false ` returns 0 while ` true ` returns 1
pub fn cast_bool_to_numeric<T>(array: &dyn Array, to: &DataType) -> Result<Box<dyn Array>>
where
    T: NativeType + num::One,
{
    let array = array.as_any().downcast_ref::<BooleanArray>().unwrap();
    let iter = array
        .iter()
        .map(|x| x.map(|x| if x { T::one() } else { T::default() }));
    // Soundness:
    //     The iterator is trustedLen
    let array = unsafe { Primitive::<T>::from_trusted_len_iter(iter) }.to(to.clone());
    Ok(Box::new(array))
}
pub fn cast_bool_to_numeric < T > ( array : & dyn Array , to : & DataType ) -> Result < Box < dyn Array > > where T : NativeType + num :: One , { let array = array . as_any ( ) . downcast_ref :: < BooleanArray > ( ) . unwrap ( ) ; let iter = array . iter ( ) . map ( | x | x . map ( | x | if x { T :: one ( ) } else { T :: default ( ) } ) ) ; // Soundness: //     The iterator is trustedLen let array = unsafe { Primitive :: < T > :: from_trusted_len_iter ( iter ) } . to ( to . clone ( ) ) ; Ok ( Box :: new ( array ) ) }
Cast Boolean types to numeric
`false` returns 0 while `true` returns 1
Cast Boolean types to numeric ` false ` returns 0 while ` true ` returns 1
array
&dyn Array
to
&DataType
array
&dyn Array
to
&DataType