Struct left_right::aliasing::Aliased[][src]

#[repr(transparent)]
pub struct Aliased<T, D> where
    D: DropBehavior
{ /* fields omitted */ }

A T that is aliased.

You should be able to mostly ignore this type, as it can generally be treated exactly like a &T. However, there are some minor exceptions around forwarding traits – since Aliased is a wrapper type around T, it cannot automatically forward traits it does not know about to &T. This means that if your &T implements, say, Serialize or some custom Borrow<Q>, Aliased<T> will not implement that same trait. You can work around this either by implementing your trait specifically for Aliased<T> where possible, or by manually dereferencing to get the &T before using the trait.

Implementations

impl<T, D> Aliased<T, D> where
    D: DropBehavior
[src]

pub unsafe fn alias(&self) -> Self[src]

Create an alias of the inner T.

Safety

This method is only safe to call as long as you ensure that the alias is never used after an Aliased<T, D> of self where D::DO_DROP is true is dropped, and as long as no &mut T is ever given out while some Aliased<T> may still be used. The returned type assumes that it is always safe to dereference into &T, which would not be true if either of those invariants were broken.

pub fn from(t: T) -> Self[src]

Construct an aliased value around a T.

This method is safe since it effectively leaks T. Note that we do not implement From<T> because we do not want users to construct Aliased<T>s on their own. If they did, they would almost certain end up with incorrect drop behavior.

pub unsafe fn change_drop<D2: DropBehavior>(self) -> Aliased<T, D2>[src]

Turn this aliased T into one with a different drop behavior.

Safety

It is always safe to change an Aliased from a dropping D to a non-dropping D. Going the other way around is only safe if self is the last alias for the T.

Trait Implementations

impl<T, D> AsRef<T> for Aliased<T, D> where
    D: DropBehavior
[src]

fn as_ref(&self) -> &T[src]

Performs the conversion.

impl<T, D> Borrow<[T]> for Aliased<Vec<T>, D> where
    D: DropBehavior
[src]

fn borrow(&self) -> &[T][src]

Immutably borrows from an owned value. Read more

impl<D> Borrow<Path> for Aliased<PathBuf, D> where
    D: DropBehavior
[src]

fn borrow(&self) -> &Path[src]

Immutably borrows from an owned value. Read more

impl<T, D> Borrow<T> for Aliased<T, D> where
    D: DropBehavior
[src]

fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T, D> Borrow<T> for Aliased<Box<T>, D> where
    T: ?Sized,
    D: DropBehavior
[src]

fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T, D> Borrow<T> for Aliased<Arc<T>, D> where
    T: ?Sized,
    D: DropBehavior
[src]

fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T, D> Borrow<T> for Aliased<Rc<T>, D> where
    T: ?Sized,
    D: DropBehavior
[src]

fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<D> Borrow<str> for Aliased<String, D> where
    D: DropBehavior
[src]

fn borrow(&self) -> &str[src]

Immutably borrows from an owned value. Read more

impl<T, D> Debug for Aliased<T, D> where
    D: DropBehavior,
    T: Debug
[src]

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

Formats the value using the given formatter. Read more

impl<T, D> Deref for Aliased<T, D> where
    D: DropBehavior
[src]

type Target = T

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl<T, D> Drop for Aliased<T, D> where
    D: DropBehavior
[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl<T, D> Hash for Aliased<T, D> where
    D: DropBehavior,
    T: Hash
[src]

fn hash<H>(&self, state: &mut H) where
    H: Hasher
[src]

Feeds this value into the given Hasher. Read more

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

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

impl<T, D> Ord for Aliased<T, D> where
    D: DropBehavior,
    T: Ord
[src]

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

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<T, D> PartialEq<Aliased<T, D>> for Aliased<T, D> where
    D: DropBehavior,
    T: PartialEq
[src]

fn eq(&self, other: &Self) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<T, D> PartialOrd<Aliased<T, D>> for Aliased<T, D> where
    D: DropBehavior,
    T: PartialOrd
[src]

fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, other: &Self) -> bool[src]

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Self) -> bool[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Self) -> bool[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Self) -> bool[src]

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

impl<T, D> Eq for Aliased<T, D> where
    D: DropBehavior,
    T: Eq
[src]

impl<T, D> Send for Aliased<T, D> where
    D: DropBehavior,
    T: Send + Sync
[src]

impl<T, D> Sync for Aliased<T, D> where
    D: DropBehavior,
    T: Sync
[src]

Auto Trait Implementations

impl<T, D> RefUnwindSafe for Aliased<T, D> where
    D: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, D> Unpin for Aliased<T, D> where
    D: Unpin,
    T: Unpin

impl<T, D> UnwindSafe for Aliased<T, D> where
    D: UnwindSafe,
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.