I want to create a shortcut for a group of 11 trait clauses in the nifti-rs project. Something like
/// Shortcut trait for reading image in generic context.
pub trait ImageReadable<T>
where
T: DataElement,
u8: AsPrimitive<T>,
i8: AsPrimitive<T>,
u16: AsPrimitive<T>,
i16: AsPrimitive<T>,
u32: AsPrimitive<T>,
i32: AsPrimitive<T>,
u64: AsPrimitive<T>,
i64: AsPrimitive<T>,
f32: AsPrimitive<T>,
f64: AsPrimitive<T>,
{}
because this pattern is repeated 10 times in nifti-rs and several times in my personal project. My goal is that, with this "super trait", the where clause of the linked function would become as simple as
fn into_ndarray<T>(self) -> Result<Array<T, IxDyn>>
where
T: ImageReadable<T>
{ ... }
However, when I try to use this shortcut, the compiler tells me that I need to add all clauses again. This is not super useful! Is this possible? What's the right syntax?