Struct rt_ref::Ref

source ·
pub struct Ref<'a, V>
where V: 'a,
{ /* private fields */ }
Expand description

Reference to a value.

Implementations§

source§

impl<'a, V> Ref<'a, V>

source

pub fn new(inner: CellRef<'a, V>) -> Self

Returns a new Ref.

source

pub fn try_clone(&self) -> Result<Self, RefOverflow>

Returns a clone of this Ref.

This method allows handling of reference overflows, but:

  • Having 2 billion (32-bit system) / 9 quintillion (64-bit system) references to an object is not a realistic scenario in most applications.

  • Applications that hold Refs with an ever-increasing reference count are not supported by this library.

    Reaching isize::MAX may be possible with std::mem::forget(Ref::clone(&r)).

Trait Implementations§

source§

impl<'a, V> Clone for Ref<'a, V>

source§

fn clone(&self) -> Self

Returns a clone of this Ref.

§Panics

Panics if the number of references is isize::MAX:

  • Having 2 billion / 9 quintillion references to an object is not a realistic scenario in most applications.

  • Applications that hold Refs with an ever-increasing reference count are not supported by this library.

    Reaching isize::MAX may be possible with std::mem::forget(Ref::clone(&r)).

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a, V> Debug for Ref<'a, V>
where V: Debug + 'a,

source§

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

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

impl<'a, V> Deref for Ref<'a, V>

§

type Target = V

The resulting type after dereferencing.
source§

fn deref(&self) -> &V

Dereferences the value.
source§

impl<'a, V> PartialEq for Ref<'a, V>
where V: PartialEq + 'a,

source§

fn eq(&self, other: &Self) -> 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.

Auto Trait Implementations§

§

impl<'a, V> RefUnwindSafe for Ref<'a, V>
where V: RefUnwindSafe,

§

impl<'a, V> Send for Ref<'a, V>
where V: Sync,

§

impl<'a, V> Sync for Ref<'a, V>
where V: Sync,

§

impl<'a, V> Unpin for Ref<'a, V>

§

impl<'a, V> UnwindSafe for Ref<'a, V>
where V: RefUnwindSafe,

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> ToOwned for T
where 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 T
where 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 T
where 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.