Enum XRefMut

Source
pub enum XRefMut<'a, T> {
    Borrowed(&'a mut T),
    Ref(RefMut<'a, T>),
    Owned(T),
}
Expand description

Kind of like Cow, but might also be a RefMut (from a RefCell) Also, does not use ToOwned. This is because the main point of an XRefMut is not to Copy On Write, but to either hold an owned value or a reference to a value

Variants§

§

Borrowed(&'a mut T)

§

Ref(RefMut<'a, T>)

§

Owned(T)

Implementations§

Source§

impl<'a, T> XRefMut<'a, T>

Source

pub fn to_ref(&self) -> &T

Source

pub fn to_mut(&mut self) -> &mut T

Source§

impl<'a, T> XRefMut<'a, T>
where T: Clone,

Source

pub fn into_owned(self) -> T

Extracts the owned data. Clones the data if it is not already owned.

Trait Implementations§

Source§

impl<'a, T> AsRef<T> for XRefMut<'a, T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, T> Borrow<T> for XRefMut<'a, T>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<'a, T> Debug for XRefMut<'a, T>
where T: Debug,

Source§

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

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

impl<'a, T> Default for XRefMut<'a, T>
where T: Default,

Source§

fn default() -> XRefMut<'a, T>

Returns the “default value” for a type. Read more
Source§

impl<'a, T> DerefMut for XRefMut<'a, T>

Source§

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

Mutably dereferences the value.
Source§

impl<'a, T> Display for XRefMut<'a, T>
where T: Display,

Source§

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

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

impl<'a, T> Deref for XRefMut<'a, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for XRefMut<'a, T>
where T: Freeze,

§

impl<'a, T> !RefUnwindSafe for XRefMut<'a, T>

§

impl<'a, T> !Send for XRefMut<'a, T>

§

impl<'a, T> !Sync for XRefMut<'a, T>

§

impl<'a, T> Unpin for XRefMut<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for XRefMut<'a, T>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V