Skip to main content

JsonValue

Enum JsonValue 

Source
pub enum JsonValue {
    Null,
    Boolean(bool),
    Number(JsonNumberBuf),
    String(JsonString),
    Array(JsonArrayBuf),
    Object(JsonObject),
}
Expand description

JSON Value.

§Parsing

You can parse a Value by importing the JsonParse trait providing a collection of parsing functions.

§Example

use json_syntax::{JsonValue, JsonParse, JsonCodeMap};
let (value, code_map) = JsonValue::parse_str("{ \"key\": \"value\" }").unwrap();

The code_map value of type JsonCodeMap contains code-mapping information about all the fragments of the JSON value (their location in the source text).

§Comparison

The PartialEq and PartialOrd implementations will compare the JSON values semantically, without regard for the object entries indexes. The only exception is when one key has multiple values, in which cases the values are ordered by index. It is possible to compare the lexical representation of objects (where the entries indexes matter) by using the JsonBorrowLexical::as_lexical method on both ends and comparing the results.

§Example

use json_syntax::{json, lexical::JsonBorrowLexical};

let a = json!({ "a": 0, "b": 1 });
let b = json!({ "b": 1, "a": 0 });

assert_eq!(a, b); // equals, because semantically equivalent.
assert_ne!(a.as_lexical(), b.as_lexical()); // not equals.

§Printing

The JsonPrint trait provide a highly configurable printing method.

§Example

use json_syntax::{JsonValue, JsonParse, JsonPrint};

let value = JsonValue::parse_str("[ 0, 1, { \"key\": \"value\" }, null ]").unwrap().0;

println!("{}", value.pretty_print()); // multi line, indent with 2 spaces
println!("{}", value.inline_print()); // single line, spaces
println!("{}", value.compact_print()); // single line, no spaces

let mut options = json_syntax::print::JsonPrintOptions::PRETTY;
options.indent = json_syntax::print::Indent::Tabs(1);
println!("{}", value.print_with(&options)); // multi line, indent with tabs

Variants§

§

Null

null.

§

Boolean(bool)

Boolean true or false.

§

Number(JsonNumberBuf)

Number.

§

String(JsonString)

String.

§

Array(JsonArrayBuf)

Array.

§

Object(JsonObject)

Object.

Implementations§

Source§

impl JsonValue

Source

pub fn from_serde_json(value: Value) -> Self

Converts a serde_json::Value into a Value.

§Example
use json_syntax::JsonValue;

// First we create a `serde_json` value.
let a = serde_json::json!({
  "foo": 1,
  "bar": [2, 3]
});

// We convert the `serde_json` value into a `json_syntax` value.
let b = JsonValue::from_serde_json(a);

// We convert it back into a `serde_json` value.
let _ = JsonValue::into_serde_json(b);
Source

pub fn into_serde_json(self) -> Value

Converts a Value into a serde_json::Value.

§Example
use json_syntax::JsonValue;

// First we create a `serde_json` value.
let a = serde_json::json!({
  "foo": 1,
  "bar": [2, 3]
});

// We convert the `serde_json` value into a `json_syntax` value.
let b = JsonValue::from_serde_json(a);

// We convert it back into a `serde_json` value.
let _ = JsonValue::into_serde_json(b);
Source§

impl JsonValue

Source

pub fn locate_fragment( &self, code_map: &JsonCodeMap, path: &JsonFragmentPath, ) -> Option<usize>

Returns the JsonCodeMap index of the fragment described by path.

The returned index can be used to look up the byte span of the fragment in the code_map produced by parsing the same document.

Returns None if the path does not exist in this value (e.g., the key is missing, the array index is out of range, or a path segment tries to navigate into a fragment that has no sub-fragments).

§Segment semantics
  • [JsonFragmentPathSegment::ArrayIndex]: navigates into the i-th element of an array.
  • [JsonFragmentPathSegment::ObjectKey]: navigates to the key string fragment of the n-th occurrence of the named key. This is a terminal step; further path segments after this will return None.
  • [JsonFragmentPathSegment::ObjectValue]: navigates to the value of the n-th occurrence of the named key.
Source§

impl JsonValue

Source

pub fn find_duplicate_key_recursive( &self, ) -> Option<(JsonFragmentPathBuf, &str)>

Recursively searches this value, including nested arrays and objects, for the first object containing a duplicate key.

Many JSON-based formats (such as JSON-LD) require object keys to be unique throughout a document, even though JSON itself only recommends it; this can be used to validate a whole document in one pass before processing it, rather than checking every object individually as it is encountered.

Returns the path to the first object found with a duplicate key (relative to self), together with the duplicated key itself, or None if no object anywhere in this value has a duplicate key. The returned path can be passed to JsonValue::locate_fragment (with an empty final segment, or combined with JsonBacktraceBuilder methods) to locate the offending object in a parsed document.

Source§

impl JsonValue

Source

pub fn get_fragment(&self, index: usize) -> Result<JsonFragment<'_>, usize>

Source

pub fn kind(&self) -> JsonKind

Source

pub fn is_kind(&self, kind: JsonKind) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn is_boolean(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn is_object(&self) -> bool

Source

pub fn is_empty_array_or_object(&self) -> bool

Checks if the value is either an empty array or an empty object.

Source

pub fn as_boolean(&self) -> Option<bool>

Source

pub fn as_boolean_mut(&mut self) -> Option<&mut bool>

Source

pub fn as_number(&self) -> Option<&JsonNumber>

Source

pub fn as_number_mut(&mut self) -> Option<&mut JsonNumberBuf>

Source

pub fn as_string(&self) -> Option<&str>

Source

pub fn as_str(&self) -> Option<&str>

Alias for as_string.

Source

pub fn as_string_mut(&mut self) -> Option<&mut JsonString>

Source

pub fn as_array(&self) -> Option<&[Self]>

Source

pub fn as_array_mut(&mut self) -> Option<&mut JsonArrayBuf>

Source

pub fn force_as_array(&self) -> &[Self]

Return the given value as an array, even if it is not an array.

Returns the input value as is if it is already an array, or puts it in a slice with a single element if it is not.

Source

pub fn as_object(&self) -> Option<&JsonObject>

Source

pub fn as_object_mut(&mut self) -> Option<&mut JsonObject>

Source

pub fn into_boolean(self) -> Option<bool>

Source

pub fn into_number(self) -> Option<JsonNumberBuf>

Source

pub fn into_string(self) -> Option<JsonString>

Source

pub fn into_array(self) -> Option<JsonArrayBuf>

Source

pub fn into_object(self) -> Option<JsonObject>

Source

pub fn traverse(&self) -> Traverse<'_> ⓘ

Source

pub fn count(&self, f: impl FnMut(usize, JsonFragment<'_>) -> bool) -> usize

Recursively count the number of values for which f returns true.

Source

pub fn volume(&self) -> usize

Returns the volume of the value.

The volume is the sum of all values and recursively nested values included in self, including self (the volume is at least 1).

This is equivalent to value.traverse().filter(|(_, f)| f.is_value()).count().

Source

pub fn take(&mut self) -> Self

Move and return the value, leaves null in its place.

Source

pub fn canonicalize_with(&mut self, buffer: &mut Buffer)

Puts this JSON value in canonical form according to RFC 8785.

The given buffer is used to canonicalize the number values.

Source

pub fn canonicalize(&mut self)

Puts this JSON value in canonical form according to RFC 8785.

Source

pub fn canonicalized(&self) -> Self

Returns the canonical form of this value according to RFC 8785.

Trait Implementations§

Source§

impl Clone for JsonValue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsonValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for JsonValue

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserializer<'de> for JsonValue

Source§

type Error = DeserializeError

The error type that can be returned if some error occurs during deserialization.
Source§

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
Source§

fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
Source§

fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
Source§

fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
Source§

fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
Source§

fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
Source§

fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
Source§

fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
Source§

fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
Source§

fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
Source§

fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
Source§

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
Source§

fn deserialize_enum<V>( self, _name: &str, _variants: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
Source§

fn deserialize_newtype_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
Source§

fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
Source§

fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
Source§

fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
Source§

fn deserialize_unit_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
Source§

fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
Source§

fn deserialize_tuple<V>( self, _len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
Source§

fn deserialize_tuple_struct<V>( self, _name: &'static str, _len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
Source§

fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
Source§

fn deserialize_struct<V>( self, _name: &'static str, _fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
Source§

fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
Source§

fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
Source§

impl Display for JsonValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for JsonValue

Source§

impl<'n> From<&'n JsonNumber> for JsonValue

Source§

fn from(n: &'n JsonNumber) -> Self

Converts to this type from the input type.
Source§

impl<'s> From<&'s str> for JsonValue

Source§

fn from(s: &'s str) -> Self

Converts to this type from the input type.
Source§

impl From<JsonNumberBuf> for JsonValue

Source§

fn from(n: JsonNumberBuf) -> Self

Converts to this type from the input type.
Source§

impl From<JsonObject> for JsonValue

Source§

fn from(o: JsonObject) -> Self

Converts to this type from the input type.
Source§

impl From<JsonValue> for Value

Source§

fn from(value: JsonValue) -> Self

Converts to this type from the input type.
Source§

impl From<JsonValue> for String

Source§

fn from(value: JsonValue) -> Self

Converts to this type from the input type.
Source§

impl From<SmallString<[u8; 16]>> for JsonValue

Source§

fn from(s: JsonString) -> Self

Converts to this type from the input type.
Source§

impl From<String> for JsonValue

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for JsonValue

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<JsonValue>> for JsonValue

Source§

fn from(a: JsonArrayBuf) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for JsonValue

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for JsonValue

Source§

fn from(n: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for JsonValue

Source§

fn from(n: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for JsonValue

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for JsonValue

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for JsonValue

Source§

fn from(n: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for JsonValue

Source§

fn from(n: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for JsonValue

Source§

fn from(n: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for JsonValue

Source§

fn from(n: u64) -> Self

Converts to this type from the input type.
Source§

impl FromStr for JsonValue

Source§

type Err = JsonParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for JsonValue

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'de> IntoDeserializer<'de, DeserializeError> for JsonValue

Source§

type Deserializer = JsonValue

The type of the deserializer being converted into.
Source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.
Source§

impl JsonBorrowLexical for JsonValue

Source§

fn as_lexical(&self) -> &JsonLexical<Self>

Source§

impl JsonLexicalEq for JsonValue

Source§

impl JsonLexicalPartialEq for JsonValue

Source§

fn lexical_eq(&self, other: &Self) -> bool

Source§

impl JsonParse for JsonValue

Source§

fn parse_in<C, E>( parser: &mut Parser<C, E>, context: JsonParsingContext, ) -> Result<(Self, usize), JsonParseError<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

Source§

fn parse_slice(content: &[u8]) -> Result<(Self, JsonCodeMap), JsonParseError>

Source§

fn parse_slice_with( content: &[u8], options: Options, ) -> Result<(Self, JsonCodeMap), JsonParseError>

Source§

fn parse_str(content: &str) -> Result<(Self, JsonCodeMap), JsonParseError>

Source§

fn parse_str_with( content: &str, options: Options, ) -> Result<(Self, JsonCodeMap), JsonParseError>

Source§

fn parse_infallible_utf8<C>( chars: C, ) -> Result<(Self, JsonCodeMap), JsonParseError>
where C: Iterator<Item = char>,

Source§

fn parse_utf8_infallible_with<C>( chars: C, options: Options, ) -> Result<(Self, JsonCodeMap), JsonParseError>
where C: Iterator<Item = char>,

Source§

fn parse_utf8<C, E>(chars: C) -> Result<(Self, JsonCodeMap), JsonParseError<E>>
where C: Iterator<Item = Result<char, E>>,

Source§

fn parse_utf8_with<C, E>( chars: C, options: Options, ) -> Result<(Self, JsonCodeMap), JsonParseError<E>>
where C: Iterator<Item = Result<char, E>>,

Source§

fn parse_infallible<C>(chars: C) -> Result<(Self, JsonCodeMap), JsonParseError>
where C: Iterator<Item = DecodedChar>,

Source§

fn parse_infallible_with<C>( chars: C, options: Options, ) -> Result<(Self, JsonCodeMap), JsonParseError>
where C: Iterator<Item = DecodedChar>,

Source§

fn parse<C, E>(chars: C) -> Result<(Self, JsonCodeMap), JsonParseError<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

Source§

fn parse_with<C, E>( chars: C, options: Options, ) -> Result<(Self, JsonCodeMap), JsonParseError<E>>
where C: Iterator<Item = Result<DecodedChar, E>>,

Source§

impl JsonVisit for JsonValue

Source§

fn visit<V: JsonVisitor>(&self, visitor: V) -> V::Output

Source§

impl Ord for JsonValue

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for JsonValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for JsonValue

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for JsonValue

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for JsonValue

Source§

impl TryFrom<f32> for JsonValue

Source§

type Error = TryFromFloatError

The type returned in the event of a conversion error.
Source§

fn try_from(n: f32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f64> for JsonValue

Source§

type Error = TryFromFloatError

The type returned in the event of a conversion error.
Source§

fn try_from(n: f64) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> JsonAt for T

Source§

fn json_at<F>( self, location: impl Into<Vec<JsonBacktraceFrame<F>>>, ) -> JsonLocated<T, F>

Pairs self with location.
Source§

impl<T> JsonPrint for T
where T: JsonVisit,

Source§

fn fmt_with( &self, f: &mut Formatter<'_>, options: &JsonPrintOptions, indent: usize, ) -> Result<(), Error>

Source§

fn pretty_print(&self) -> Printed<'_, 'static, Self>

Print the value with Options::pretty options.
Source§

fn compact_print(&self) -> Printed<'_, 'static, Self>

Print the value with Options::compact options.
Source§

fn inline_print(&self) -> Printed<'_, 'static, Self>

Print the value with Options::inline options.
Source§

fn print_with<'o>(&self, options: &'o JsonPrintOptions) -> Printed<'_, 'o, Self>

Print the value with the given options.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.