polars_core/utils/
any_value.rsuse crate::prelude::*;
use crate::utils::dtypes_to_supertype;
pub fn any_values_to_supertype<'a, I>(values: I) -> PolarsResult<DataType>
where
I: IntoIterator<Item = &'a AnyValue<'a>>,
{
let dtypes = any_values_to_dtype_set(values);
dtypes_to_supertype(&dtypes)
}
pub fn any_values_to_supertype_and_n_dtypes<'a, I>(values: I) -> PolarsResult<(DataType, usize)>
where
I: IntoIterator<Item = &'a AnyValue<'a>>,
{
let dtypes = any_values_to_dtype_set(values);
let supertype = dtypes_to_supertype(&dtypes)?;
let n_dtypes = dtypes.len();
Ok((supertype, n_dtypes))
}
fn any_values_to_dtype_set<'a, I>(values: I) -> PlIndexSet<DataType>
where
I: IntoIterator<Item = &'a AnyValue<'a>>,
{
values.into_iter().map(|av| av.into()).collect()
}