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
6940 views
1
use polars_utils::pl_str::PlSmallStr;
2
3
use super::{AnyValue, DataType, Scalar};
4
5
macro_rules! impl_from {
6
($(($t:ty, $av:ident, $dt:ident))+) => {
7
$(
8
impl From<$t> for Scalar {
9
#[inline]
10
fn from(v: $t) -> Self {
11
Self::new(DataType::$dt, AnyValue::$av(v))
12
}
13
}
14
)+
15
}
16
}
17
18
impl_from! {
19
(bool, Boolean, Boolean)
20
(i8, Int8, Int8)
21
(i16, Int16, Int16)
22
(i32, Int32, Int32)
23
(i64, Int64, Int64)
24
(i128, Int128, Int128)
25
(u8, UInt8, UInt8)
26
(u16, UInt16, UInt16)
27
(u32, UInt32, UInt32)
28
(u64, UInt64, UInt64)
29
(f32, Float32, Float32)
30
(f64, Float64, Float64)
31
(PlSmallStr, StringOwned, String)
32
(Vec<u8>, BinaryOwned, Binary)
33
}
34
35