macro_rules! from_primitive {
(float_f for: $for:ident + $for_b:expr, from: $from:ident + $( $from_b:expr ),+) => {
$( from_primitive![@float_f for: $for + $for_b, from: $from + $from_b]; )+
};
(@float_f for: $for:ident + $for_b:expr, from: $from:ident + $from_b:expr) => {
$crate::all::impl_from!(for: $for+$for_b, from: $from+$from_b, arg:f, body: {
Self(f.into())
});
$crate::all::impl_from!(for: $for+$for_b, from: &$from+$from_b, arg:f, body: {
Self((*f).into())
});
};
(float_half for: $for:ident + $for_b:expr, from: $from:ident + $( $from_b:expr ),+) => {
$( from_primitive![@float_half for: $for + $for_b, from: $from + $from_b]; )+
};
(@float_half for: $for:ident + $for_b:expr, from: $from:ident + $from_b:expr) => {
$crate::all::impl_from!(for: $for+$for_b, from: @$from+$from_b, arg:f, body: {
f.to_f32().into()
});
};
(float_tf for: $for:ident + $for_b:expr, from: $from:ident + $( $from_b:expr ),+) => {
$( from_primitive![@float_tf for: $for + $for_b, from: $from + $from_b]; )+
};
(@float_tf for: $for:ident + $for_b:expr, from: $from:ident + $from_b:expr) => {
$crate::all::impl_from!(for: $for+$for_b, from: $from+$from_b, arg:f, body: {
Self(f.into())
});
$crate::all::impl_from!(for: $for+$for_b, from: &$from+$from_b, arg:f, body: {
Self((*f).into())
});
};
(float_tf_half for: $for:ident + $for_b:expr, from: $from:ident + $( $from_b:expr ),+) => {
$( from_primitive![@float_tf_half for: $for + $for_b, from: $from + $from_b]; )+
};
(@float_tf_half for: $for:ident + $for_b:expr, from: $from:ident + $from_b:expr) => {
$crate::all::impl_from!(for: $for+$for_b, from: @$from+$from_b, arg:f, body: {
Self(f.to_f32().into())
});
};
}
pub(crate) use from_primitive;