Skip to content

Commit

Permalink
Delete Value::as_i128
Browse files Browse the repository at this point in the history
This is adequately supported by `value.as_number().and_then(Number::as_i128)`
  • Loading branch information
dtolnay committed Oct 18, 2024
1 parent fb12a9d commit 1a944f4
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,24 +635,6 @@ impl Value {
}
}

/// If the `Value` is an integer, represent it as i128 if possible. Returns
/// None otherwise.
///
/// ```
/// # use serde_json::json;
/// #
/// let v = json!({ "a": 64, "b": 256.0 });
///
/// assert_eq!(v["a"].as_i128(), Some(64));
/// assert_eq!(v["b"].as_i128(), None);
/// ```
pub fn as_i128(&self) -> Option<i128> {
match self {
Value::Number(n) => n.as_i128(),
_ => None,
}
}

/// If the `Value` is an integer, represent it as u64 if possible. Returns
/// None otherwise.
///
Expand Down

0 comments on commit 1a944f4

Please sign in to comment.