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