devela 0.27.0

A development layer of coherence.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// devela::phys::unit::_helpers

// Implements TryFrom for `$to_prim` from the `$unit` type `$from_prim` value
macro_rules! impl_try_from {
    ($unit:ty, $from_prim:ty => $($to_prim:ty),+) => {
        $( impl_try_from![@$unit, $from_prim => $to_prim]; )+
    };

    (@$unit:ty, $from_prim:ty => $to_prim:ty) => {
        impl TryFrom<$unit> for $to_prim {
            type Error = $crate::Overflow;
            fn try_from(from: $unit) -> Result<$to_prim, Self::Error> { crate::paste! {
                $crate::Cast($from_prim::from(from)).[< checked_cast_to_ $to_prim>]()
            }}
        }
    };
}
pub(super) use impl_try_from;