use num::complex::Complex;
use num::rational::Ratio;
use num::{Integer, Num};
use std::num::Wrapping;
pub trait GradientType<OutputType> {
type GradientType;
}
macro_rules! impl_simple_types {
($($type:ty),*) => {
$(
impl<T> GradientType<T> for $type {
type GradientType = T;
}
)*
};
}
impl_simple_types!(
f32,
f64,
i8,
i16,
i32,
i64,
u8,
u16,
u32,
u64,
u128,
i128,
usize,
isize,
num::BigInt,
num::BigUint,
Complex<f32>,
Complex<f64>
);
impl<T, U> GradientType<U> for Ratio<T>
where
T: Integer + Clone,
U: Num + Clone,
{
type GradientType = Ratio<U>;
}
impl<T, U> GradientType<U> for Wrapping<T>
where
T: Integer + Clone,
U: Num + Clone,
{
type GradientType = Wrapping<U>;
}