Skip to main content

svod_dtype/
ext.rs

1use super::*;
2
3pub trait HasDType {
4    const DTYPE: DType;
5}
6
7macro_rules! impl_dtype_ext {
8    ($($ty:ty => $dtype:expr),* $(,)?) => {
9        $(impl HasDType for $ty { const DTYPE: DType = $dtype; })*
10    };
11}
12
13impl_dtype_ext! {
14    bool => DType::Bool,
15    i8 => DType::Int8, i16 => DType::Int16, i32 => DType::Int32, i64 => DType::Int64,
16    u8 => DType::UInt8, u16 => DType::UInt16, u32 => DType::UInt32, u64 => DType::UInt64,
17    f32 => DType::Float32, f64 => DType::Float64,
18}