Macro serde_json_lodash::to_safe_integer_x
source · [−]macro_rules! to_safe_integer_x {
() => { ... };
($a:expr $(,)*) => { ... };
($a:expr, $($rest:tt)*) => { ... };
}
Expand description
Based on to_safe_integer_x()
Examples:
#[macro_use] extern crate serde_json_lodash;
use serde_json::json;
assert_eq!(
to_safe_integer_x!(json!(3.2)),
3
);
//assert_eq!(
// to_safe_integer_x!(json!(isize::MIN)), // serde_json will convert this to Number(-9223372036854775808)
// 0
//);
//assert_eq!(
// to_safe_integer_x!(json!(f64::INFINITY)), // serde_json will convert this to Value::Null
// 9007199254740991 // serde_json will convert this to Number(-1)
//);
assert_eq!(
to_safe_integer_x!(json!("3.2")),
3
);
More examples:
assert_eq!(to_safe_integer_x!(), 0);