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

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

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.

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.

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

Converts this type into a shared reference of the (usually inferred) input type.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Executes the destructor for this type. Read more

Feeds this value into the given Hasher. Read more

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

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

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

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

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.