Skip to content

Commit

Permalink
Make RawValue::is_* methods pub
Browse files Browse the repository at this point in the history
  • Loading branch information
bheylin committed Dec 11, 2024
1 parent 511c27b commit 156f5d5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}
}
Expand Down

0 comments on commit 156f5d5

Please sign in to comment.