Skip to content

Commit

Permalink
Move RawValue associated constants into same impl block as public fun…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
dtolnay committed Dec 11, 2024
1 parent 96576ba commit f42c7c7
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 f42c7c7

Please sign in to comment.