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

#[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]

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

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

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

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

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

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

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

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

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

type Target = T

The resulting type after dereferencing.

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

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

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

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

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

impl<T, D> PartialOrd<Aliased<T, D>> for Aliased<T, D> where
    D: DropBehavior,
    T: PartialOrd
[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
[src]

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

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

Blanket Implementations

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

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

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

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

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

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.

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.