Skip to content

Commit

Permalink
Merge pull request #1222 from dtolnay/rawvalueassoc
Browse files Browse the repository at this point in the history
Move RawValue associated constants into same impl block as public functions
  • Loading branch information
dtolnay authored Dec 11, 2024
2 parents 96576ba + f42c7c7 commit 4aa05b9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ pub struct RawValue {
}

impl RawValue {
/// A literal JSON null value as `RawValue`.
pub const NULL: &'static RawValue = RawValue::from_borrowed("null");
/// A literal JSON boolean true value as `RawValue`.
pub const TRUE: &'static RawValue = RawValue::from_borrowed("true");
/// A literal JSON boolean false value as `RawValue`.
pub const FALSE: &'static RawValue = RawValue::from_borrowed("false");

const fn from_borrowed(json: &str) -> &Self {
unsafe { mem::transmute::<&str, &RawValue>(json) }
}
Expand Down Expand Up @@ -175,6 +168,13 @@ impl Display for RawValue {
}

impl RawValue {
/// A literal JSON null value as `RawValue`.
pub const NULL: &'static RawValue = RawValue::from_borrowed("null");
/// A literal JSON boolean true value as `RawValue`.
pub const TRUE: &'static RawValue = RawValue::from_borrowed("true");
/// A literal JSON boolean false value as `RawValue`.
pub const FALSE: &'static RawValue = RawValue::from_borrowed("false");

/// Convert an owned `String` of JSON data to an owned `RawValue`.
///
/// This function is equivalent to `serde_json::from_str::<Box<RawValue>>`
Expand Down

0 comments on commit 4aa05b9

Please sign in to comment.