Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-core/src/scalar/from.rs
8440 views
1
use polars_utils::float16::pf16;
2
use polars_utils::pl_str::PlSmallStr;
3
4
use super::{AnyValue, DataType, Scalar};
5
6
macro_rules! impl_from {
7
($(($t:ty, $av:ident, $dt:ident))+) => {
8
$(
9
impl From<$t> for Scalar {
10
#[inline]
11
fn from(v: $t) -> Self {
12
Self::new(DataType::$dt, AnyValue::$av(v))
13
}
14
}
15
)+
16
}
17
}
18
19
impl_from! {
20
(bool, Boolean, Boolean)
21
(i8, Int8, Int8)
22
(i16, Int16, Int16)
23
(i32, Int32, Int32)
24
(i64, Int64, Int64)
25
(i128, Int128, Int128)
26
(u8, UInt8, UInt8)
27
(u16, UInt16, UInt16)
28
(u32, UInt32, UInt32)
29
(u64, UInt64, UInt64)
30
(u128, UInt128, UInt128)
31
(pf16, Float16, Float16)
32
(f32, Float32, Float32)
33
(f64, Float64, Float64)
34
(PlSmallStr, StringOwned, String)
35
(Vec<u8>, BinaryOwned, Binary)
36
}
37
38