Skip to content

Commit 06bc31e

Browse files
atomicky9prady9
authored andcommitted
Refactor Convertable to generic impl instead of macro
1 parent b515142 commit 06bc31e

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

Diff for: src/core/arith.rs

+9-22
Original file line numberDiff line numberDiff line change
@@ -376,31 +376,18 @@ pub trait Convertable {
376376
fn convert(&self) -> Array<Self::OutType>;
377377
}
378378

379-
macro_rules! convertable_type_def {
380-
($rust_type: ty) => {
381-
impl Convertable for $rust_type {
382-
type OutType = $rust_type;
379+
impl<T> Convertable for T
380+
where
381+
T: Clone + HasAfEnum + ConstGenerator<OutType = T>,
382+
<T as ConstGenerator>::OutType: HasAfEnum,
383+
{
384+
type OutType = T;
383385

384-
fn convert(&self) -> Array<Self::OutType> {
385-
constant(*self, Dim4::new(&[1, 1, 1, 1]))
386-
}
387-
}
388-
};
386+
fn convert(&self) -> Array<Self::OutType> {
387+
constant(self.clone(), Dim4::new(&[1, 1, 1, 1]))
388+
}
389389
}
390390

391-
convertable_type_def!(Complex<f64>);
392-
convertable_type_def!(Complex<f32>);
393-
convertable_type_def!(u64);
394-
convertable_type_def!(i64);
395-
convertable_type_def!(f64);
396-
convertable_type_def!(f32);
397-
convertable_type_def!(i32);
398-
convertable_type_def!(u32);
399-
convertable_type_def!(i16);
400-
convertable_type_def!(u16);
401-
convertable_type_def!(u8);
402-
convertable_type_def!(bool);
403-
404391
impl<T: HasAfEnum> Convertable for Array<T> {
405392
type OutType = T;
406393

0 commit comments

Comments
 (0)