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, const IS_MUT: bool> Reference<'a, T, IS_MUT>
impl<'a, T: ?Sized, const IS_MUT: bool> Reference<'a, T, IS_MUT>
sourcepub unsafe fn as_ref(&self) -> &'a T
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.
sourcepub unsafe fn mutable(&self) -> Reference<'a, T, true>
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.
sourcepub unsafe fn disconnect<'b>(&self) -> Reference<'b, T, IS_MUT>
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: PartialEq + ?Sized, const IS_MUT: bool> PartialEq for Reference<'a, T, IS_MUT>
impl<'a, T: PartialEq + ?Sized, const IS_MUT: bool> PartialEq for Reference<'a, T, IS_MUT>
impl<'a, T: Copy + ?Sized, const IS_MUT: bool> Copy for Reference<'a, T, IS_MUT>
impl<'a, T: Eq + ?Sized, const IS_MUT: bool> Eq for Reference<'a, T, IS_MUT>
impl<'a, T: ?Sized, const IS_MUT: bool> Send for Reference<'a, T, IS_MUT>
impl<'a, T: ?Sized, const IS_MUT: bool> StructuralEq for Reference<'a, T, IS_MUT>
impl<'a, T: ?Sized, const IS_MUT: bool> StructuralPartialEq for Reference<'a, T, IS_MUT>
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> AsReference<T> for Twhere
T: ?Sized,
impl<T> AsReference<T> for Twhere T: ?Sized,
source§fn as_reference<'a>(&'a self) -> Reference<'a, T, false>
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>
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>
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>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more