Struct Ref

Source
#[repr(transparent)]
pub struct Ref<A, T: ?Sized> { pub val: A, /* private fields */ }
Expand description

A wrapper around a base type A to indicate that the value is pointing to a value of type T.

This is not a strict type safety barrier; it is possible to convert a Ref to and from its raw version. However this can help in API documentation, as well as to assist type inference in functions like LocalMap::get.

Fields§

§val: A

The underlying storage or “raw” value.

Implementations§

Source§

impl<A, T: ?Sized> Ref<A, T>

Source

pub fn new(val: A) -> Self

Construct a new Ref by wrapping a raw value.

Trait Implementations§

Source§

impl<A: Clone, T: Clone + ?Sized> Clone for Ref<A, T>

Source§

fn clone(&self) -> Ref<A, T>

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: Debug, T: ?Sized> Debug for Ref<A, T>

Source§

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

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

impl<A, T: ?Sized> Deref for Ref<A, T>

Source§

type Target = A

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<A: Display, T: ?Sized> Display for Ref<A, T>

Source§

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

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

impl<A: FromStr, T: ?Sized> FromStr for Ref<A, T>

Source§

type Err = <A as FromStr>::Err

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'a, T: ?Sized> Index<&Ref<String, T>> for LocalMap<'a, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: &NameRef<T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T: HasId + ?Sized> Index<&Ref<String, T>> for LocalMaps<'a>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: &NameRef<T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T: ?Sized> Index<&Ref<Url, T>> for LocalMap<'a, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: &UrlRef<T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T: HasId + ?Sized> Index<&Ref<Url, T>> for LocalMaps<'a>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: &UrlRef<T>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<A, T: ?Sized> RefCast for Ref<A, T>

Source§

type From = A

Source§

fn ref_cast(_from: &Self::From) -> &Self

Source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

Source§

impl<A: Copy, T: Copy + ?Sized> Copy for Ref<A, T>

Auto Trait Implementations§

§

impl<A, T> Freeze for Ref<A, T>
where A: Freeze, T: ?Sized,

§

impl<A, T> RefUnwindSafe for Ref<A, T>

§

impl<A, T> Send for Ref<A, T>
where A: Send, T: Send + ?Sized,

§

impl<A, T> Sync for Ref<A, T>
where A: Sync, T: Sync + ?Sized,

§

impl<A, T> Unpin for Ref<A, T>
where A: Unpin, T: Unpin + ?Sized,

§

impl<A, T> UnwindSafe for Ref<A, T>
where A: UnwindSafe, T: UnwindSafe + ?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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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> 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.