More TryFrom<&SignedInteger> implementations

This commit is contained in:
Tony Garnock-Jones 2021-07-03 08:59:22 +02:00
parent 6143ddc93d
commit c7b252ca9d
1 changed files with 28 additions and 0 deletions

View File

@ -144,3 +144,31 @@ impl<'a> From<&'a SignedInteger> for BigInt {
}
}
}
impl TryFrom<&SignedInteger> for i64 {
type Error = ();
fn try_from(v: &SignedInteger) -> Result<Self, Self::Error> {
i128::try_from(v)?.try_into().map_err(|_| ())
}
}
impl TryFrom<&SignedInteger> for u64 {
type Error = ();
fn try_from(v: &SignedInteger) -> Result<Self, Self::Error> {
u128::try_from(v)?.try_into().map_err(|_| ())
}
}
impl TryFrom<&SignedInteger> for isize {
type Error = ();
fn try_from(v: &SignedInteger) -> Result<Self, Self::Error> {
i128::try_from(v)?.try_into().map_err(|_| ())
}
}
impl TryFrom<&SignedInteger> for usize {
type Error = ();
fn try_from(v: &SignedInteger) -> Result<Self, Self::Error> {
u128::try_from(v)?.try_into().map_err(|_| ())
}
}