Enum Cow

Source
pub enum Cow<'a, T: Json + 'a> {
    Borrowed(T::Borrowed<'a>),
    Owned(T),
}
Expand description

A borrowed or owned JSON value.

This type is used for the return type of JsonPath::query. It is similar to std::borrow::Cow, but is specialized for Json and JsonRef.

Variants§

§

Borrowed(T::Borrowed<'a>)

Borrowed data.

§

Owned(T)

Owned data.

Implementations§

Source§

impl<'a, T: Json> Cow<'a, T>

Source

pub fn as_ref<'b>(&'b self) -> T::Borrowed<'b>
where 'a: 'b,

Returns a reference to the JSON value.

Source

pub fn into_owned(self) -> T

Extracts the owned JSON.

Clones the JSON if it is not already owned.

Trait Implementations§

Source§

impl<'a, T: Debug + Json + 'a> Debug for Cow<'a, T>
where T::Borrowed<'a>: Debug,

Source§

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

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

impl<T: Json> Display for Cow<'_, T>
where for<'a> T::Borrowed<'a>: Display,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for Cow<'a, T>
where <T as Json>::Borrowed<'a>: Freeze, T: Freeze,

§

impl<'a, T> RefUnwindSafe for Cow<'a, T>
where <T as Json>::Borrowed<'a>: RefUnwindSafe, T: RefUnwindSafe,

§

impl<'a, T> Send for Cow<'a, T>
where <T as Json>::Borrowed<'a>: Send, T: Send,

§

impl<'a, T> Sync for Cow<'a, T>
where <T as Json>::Borrowed<'a>: Sync, T: Sync,

§

impl<'a, T> Unpin for Cow<'a, T>
where <T as Json>::Borrowed<'a>: Unpin, T: Unpin,

§

impl<'a, T> UnwindSafe for Cow<'a, T>
where <T as Json>::Borrowed<'a>: UnwindSafe, T: UnwindSafe,

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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.