use crate::traits::{Context, Make}; #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)] pub struct Scalar; macro_rules! impl_context { ( impl Context for Scalar { $(type $name:ident = $ty:ty;)* #[vec] $(type $vec_name:ident = $vec_ty:ty;)* } ) => { impl Context for Scalar { $(type $name = $ty;)* $(type $vec_name = $vec_ty;)* } $( impl Make for $ty { type Prim = $ty; type Context = Scalar; fn ctx(self) -> Self::Context { Scalar } fn make(_ctx: Self::Context, v: Self::Prim) -> Self { v } } )* }; } impl_context! { impl Context for Scalar { type Bool = bool; type U8 = u8; type I8 = i8; type U16 = u16; type I16 = i16; type F16 = crate::f16::F16; type U32 = u32; type I32 = i32; type F32 = f32; type U64 = u64; type I64 = i64; type F64 = f64; #[vec] type VecBool = bool; type VecU8 = u8; type VecI8 = i8; type VecU16 = u16; type VecI16 = i16; type VecF16 = crate::f16::F16; type VecU32 = u32; type VecI32 = i32; type VecF32 = f32; type VecU64 = u64; type VecI64 = i64; type VecF64 = f64; } }