Skip to content

Commit 5a39516

Browse files
committed
Reorder Value::as_number after is_number
The other as_* methods all come after the corresponding is_* method.
1 parent 6a5fef9 commit 5a39516

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/value/mod.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,25 @@ impl Value {
495495
}
496496
}
497497

498+
/// Returns true if the `Value` is a Number. Returns false otherwise.
499+
///
500+
/// ```
501+
/// # use serde_json::json;
502+
/// #
503+
/// let v = json!({ "a": 1, "b": "2" });
504+
///
505+
/// assert!(v["a"].is_number());
506+
///
507+
/// // The string `"2"` is a string, not a number.
508+
/// assert!(!v["b"].is_number());
509+
/// ```
510+
pub fn is_number(&self) -> bool {
511+
match *self {
512+
Value::Number(_) => true,
513+
_ => false,
514+
}
515+
}
516+
498517
/// If the `Value` is an Number, returns the associated [`Number`]. Returns
499518
/// None otherwise.
500519
///
@@ -517,25 +536,6 @@ impl Value {
517536
}
518537
}
519538

520-
/// Returns true if the `Value` is a Number. Returns false otherwise.
521-
///
522-
/// ```
523-
/// # use serde_json::json;
524-
/// #
525-
/// let v = json!({ "a": 1, "b": "2" });
526-
///
527-
/// assert!(v["a"].is_number());
528-
///
529-
/// // The string `"2"` is a string, not a number.
530-
/// assert!(!v["b"].is_number());
531-
/// ```
532-
pub fn is_number(&self) -> bool {
533-
match *self {
534-
Value::Number(_) => true,
535-
_ => false,
536-
}
537-
}
538-
539539
/// Returns true if the `Value` is an integer between `i64::MIN` and
540540
/// `i64::MAX`.
541541
///

0 commit comments

Comments
 (0)