Skip to main content

ARef

Struct ARef 

Source
pub struct ARef<'a, T: ?Sized + 'a> { /* private fields */ }
Expand description

A Ref that might not actually be borrowed. Either a Ptr (a normal & style reference), or a Ref (like from RefCell), but exposes all the methods available on Ref.

Implementations§

Source§

impl<'a, T: ?Sized + 'a> ARef<'a, T>

Source

pub fn new_ptr(x: &'a T) -> Self

Create a new ARef from a pointer.

Source

pub fn new_ref(x: Ref<'a, T>) -> Self

Create a new ARef from a reference.

Source

pub fn clone(orig: &Self) -> Self

See Ref.clone. Not a self method since that interferes with the Deref.

Source

pub fn map<U: ?Sized, F>(orig: ARef<'a, T>, f: F) -> ARef<'a, U>
where F: FnOnce(&T) -> &U,

See Ref.map. Not a self method since that interferes with the Deref.

Source

pub fn map_split<U: ?Sized, V: ?Sized, F>( orig: ARef<'a, T>, f: F, ) -> (ARef<'a, U>, ARef<'a, V>)
where F: FnOnce(&T) -> (&U, &V),

See Ref.map_split. Not a self method since that interferes with the Deref.

Source

pub fn filter_map<U: ?Sized, F>( orig: ARef<'a, T>, f: F, ) -> Result<ARef<'a, U>, Self>
where F: FnOnce(&T) -> Option<&U>,

See Ref.filter_map. Not a self method since that interferes with the Deref.

Trait Implementations§

Source§

impl<'a, T: Debug + ?Sized + 'a> Debug for ARef<'a, T>

Source§

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

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

impl<T: ?Sized> Deref for ARef<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: Display + ?Sized> Display for ARef<'_, T>

Source§

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

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

impl<T: ?Sized> Drop for ARef<'_, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<A: Eq + ?Sized> Eq for ARef<'_, A>

Source§

impl<T: Hash + ?Sized> Hash for ARef<'_, T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<A: Ord + ?Sized> Ord for ARef<'_, A>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<A: PartialEq<B> + ?Sized, B: ?Sized> PartialEq<ARef<'_, B>> for ARef<'_, A>

Source§

fn eq(&self, other: &ARef<'_, B>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<A: PartialOrd<B> + ?Sized, B: ?Sized> PartialOrd<ARef<'_, B>> for ARef<'_, A>

Source§

fn partial_cmp(&self, other: &ARef<'_, B>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'a, T> Freeze for ARef<'a, T>
where T: ?Sized,

§

impl<'a, T> Unpin for ARef<'a, T>
where T: ?Sized,

§

impl<'a, T> UnsafeUnpin for ARef<'a, T>
where T: ?Sized,

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> AsARef<T> for T
where T: ?Sized,

Source§

fn as_aref(this: &T) -> ARef<'_, T>

Get an ARef pointing at this type.
Source§

fn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>

Try and get an ARef pointing at this type. Returns an Err if the type Self is a RefCell which is already mutably borrowed.
Source§

fn as_ref_cell(_this: &T) -> Option<&RefCell<T>>

Return the underlying RefCell if Self is one, otherwise None.
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> TEq<T> for T

Source§

fn teq(self) -> T

Convert between two equal types.
Source§

fn teq_ref(&self) -> &T

Convert between references to two equal types.
Source§

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

Convert between mutable references to two equal types.
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.