mirror of
https://github.com/serde-rs/json.git
synced 2025-11-16 21:35:47 +00:00
Flatten logic in Number::from_i128
This commit is contained in:
parent
22973d2783
commit
c3149efd62
@ -314,8 +314,7 @@ impl Number {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_i128(i: i128) -> Option<Number> {
|
pub fn from_i128(i: i128) -> Option<Number> {
|
||||||
match u64::try_from(i) {
|
if let Ok(u) = u64::try_from(i) {
|
||||||
Ok(u) => {
|
|
||||||
let n = {
|
let n = {
|
||||||
#[cfg(not(feature = "arbitrary_precision"))]
|
#[cfg(not(feature = "arbitrary_precision"))]
|
||||||
{
|
{
|
||||||
@ -327,9 +326,7 @@ impl Number {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Some(Number { n })
|
Some(Number { n })
|
||||||
}
|
} else if let Ok(i) = i64::try_from(i) {
|
||||||
Err(_) => match i64::try_from(i) {
|
|
||||||
Ok(i) => {
|
|
||||||
let n = {
|
let n = {
|
||||||
#[cfg(not(feature = "arbitrary_precision"))]
|
#[cfg(not(feature = "arbitrary_precision"))]
|
||||||
{
|
{
|
||||||
@ -341,9 +338,8 @@ impl Number {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Some(Number { n })
|
Some(Number { n })
|
||||||
}
|
} else {
|
||||||
Err(_) => None,
|
None
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user