From 156f5d5f1aaaa1bb22662c630f653e250c638803 Mon Sep 17 00:00:00 2001 From: Brian Heylin <3947+bheylin@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:56:04 +0100 Subject: [PATCH] Make `RawValue::is_*` methods `pub` --- src/raw.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/raw.rs b/src/raw.rs index c5d70948a..01b928c5f 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -229,7 +229,7 @@ impl RawValue { } /// Returns the kind of JSON value contained within. - fn kind(&self) -> RawKind { + pub fn kind(&self) -> RawKind { let first = self .json .as_bytes() @@ -238,7 +238,7 @@ impl RawValue { // `RawValue` has whitespace stripped so we know the first char is non-whitespace. // `RawValue` is also valid JSON so the only possible set of chars that can come next - // are `[0-9]` or `[-fnt"[{]`. + // are `[0-9]` or `[-pub fnt"[{]`. match *first { b'n' => RawKind::Null, b't' | b'f' => RawKind::Bool, @@ -264,7 +264,7 @@ impl RawValue { /// // The boolean `false` is not null. /// assert!(!v["b"].is_null()); /// ``` - fn is_null(&self) -> bool { + pub fn is_null(&self) -> bool { matches!(self.kind(), RawKind::Null) } @@ -281,7 +281,7 @@ impl RawValue { /// // The string `"false"` is a string, not a boolean. /// assert!(!v["b"].is_boolean()); /// ``` - fn is_boolean(&self) -> bool { + pub fn is_boolean(&self) -> bool { matches!(self.kind(), RawKind::Bool) } @@ -298,7 +298,7 @@ impl RawValue { /// // The string `"2"` is a string, not a number. /// assert!(!v["b"].is_number()); /// ``` - fn is_number(&self) -> bool { + pub fn is_number(&self) -> bool { matches!(self.kind(), RawKind::Number) } @@ -315,7 +315,7 @@ impl RawValue { /// // The boolean `false` is not a string. /// assert!(!v["b"].is_string()); /// ``` - fn is_string(&self) -> bool { + pub fn is_string(&self) -> bool { matches!(self.kind(), RawKind::String) } @@ -332,7 +332,7 @@ impl RawValue { /// // an object, not an array /// assert!(!obj["b"].is_array()); /// ``` - fn is_array(&self) -> bool { + pub fn is_array(&self) -> bool { matches!(self.kind(), RawKind::Array) } @@ -350,7 +350,7 @@ impl RawValue { /// // array, not an object /// assert!(!obj["b"].is_object()); /// ``` - fn is_object(&self) -> bool { + pub fn is_object(&self) -> bool { matches!(self.kind(), RawKind::Object) } }