Struct deborrow::Reference

source ·
pub struct Reference<'a, T: ?Sized, const IS_MUT: bool> { /* private fields */ }
Expand description

A reference which can be shared between threads and converted back into normal refs anywhere.

Implementations§

source§

impl<'a, T: ?Sized> Reference<'a, T, false>

source

pub fn from_ref(r: &'a T) -> Self

Constructs a Reference from a non-mutable reference

source§

impl<'a, T: ?Sized> Reference<'a, T, true>

source

pub fn from_mut(r: &'a mut T) -> Self

Constructs a Reference from a mutable reference

source

pub unsafe fn as_mut(&self) -> Option<&'a mut T>

Turns the Reference into a mutable ref if it has been created from a mutable ref.

source§

impl<'a, T: ?Sized, const IS_MUT: bool> Reference<'a, T, IS_MUT>

source

pub unsafe fn as_ref(&self) -> &'a T

Turns the Reference into a non-mutable ref.

SAFETY:

This function is only safe until the reference has been “polluted” by a call to any as_mut.

source

pub unsafe fn mutable(&self) -> Reference<'a, T, true>

Turns the Reference into a mutable ref even if it has been created from a non-mutable ref.

source

pub unsafe fn disconnect<'b>(&self) -> Reference<'b, T, IS_MUT>

Deborrows the Reference, returning a new one with a disconnected lifetime.

Trait Implementations§

source§

impl<'a, T: Clone + ?Sized, const IS_MUT: bool> Clone for Reference<'a, T, IS_MUT>

source§

fn clone(&self) -> Reference<'a, T, IS_MUT>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a, T: Debug + ?Sized, const IS_MUT: bool> Debug for Reference<'a, T, IS_MUT>

source§

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

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

impl<'a, T: PartialEq + ?Sized, const IS_MUT: bool> PartialEq for Reference<'a, T, IS_MUT>

source§

fn eq(&self, other: &Reference<'a, T, IS_MUT>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T: Copy + ?Sized, const IS_MUT: bool> Copy for Reference<'a, T, IS_MUT>

source§

impl<'a, T: Eq + ?Sized, const IS_MUT: bool> Eq for Reference<'a, T, IS_MUT>

source§

impl<'a, T: ?Sized, const IS_MUT: bool> Send for Reference<'a, T, IS_MUT>

source§

impl<'a, T: ?Sized, const IS_MUT: bool> StructuralEq for Reference<'a, T, IS_MUT>

source§

impl<'a, T: ?Sized, const IS_MUT: bool> StructuralPartialEq for Reference<'a, T, IS_MUT>

source§

impl<'a, T: ?Sized, const IS_MUT: bool> Sync for Reference<'a, T, IS_MUT>

Auto Trait Implementations§

§

impl<'a, T: ?Sized, const IS_MUT: bool> RefUnwindSafe for Reference<'a, T, IS_MUT>where T: RefUnwindSafe,

§

impl<'a, T: ?Sized, const IS_MUT: bool> Unpin for Reference<'a, T, IS_MUT>

§

impl<'a, T: ?Sized, const IS_MUT: bool> UnwindSafe for Reference<'a, T, IS_MUT>where T: RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsReference<T> for Twhere T: ?Sized,

source§

fn as_reference<'a>(&'a self) -> Reference<'a, T, false>

Turns this non-mutable ref into a Reference type
source§

fn as_mut_reference<'a>(&'a mut self) -> Reference<'a, T, true>

Turns this mutable ref into a Reference type
source§

unsafe fn as_deborrowed_reference<'b, 'a>(&'a self) -> Reference<'b, T, false>

Turns this non-mutable ref into a Reference type with a disconnected lifetime.
source§

unsafe fn as_deborrowed_mut_reference<'b, 'a>( &'a mut self ) -> Reference<'b, T, true>

Turns this mutable ref into a Reference type with a disconnected lifetime.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.