pub trait Code: Into<u8> + core::convert::TryFrom<u8> {}
impl Code for u8 {}
pub trait OptionNumber: Into<u16> + core::convert::TryFrom<u16> {}
impl OptionNumber for u16 {}
pub trait FromOtherOption<O: OptionNumber> {
type Error;
fn convert_from_other(other: O) -> Result<Self, Self::Error>
where
Self: Sized;
}
impl<O: OptionNumber, T: OptionNumber> FromOtherOption<O> for T
{
type Error = <Self as core::convert::TryFrom<u16>>::Error;
fn convert_from_other(other: O) -> Result<Self, Self::Error>
where
Self: Sized
{
let num: u16 = other.into();
use core::convert::TryInto;
num.try_into()
}
}