[][src]Struct galemu::Bound

pub struct Bound<'a, T: BoundExt<'a>> { /* fields omitted */ }

Workaround for rust not having generic associated lifetimes (GAT/GAL).

General Safety Aspects

Bound<'a, T> binds a lifetimes 'a to a instance of a type T. It guarantees on a safety level that rebinding to any lifetimes which is not a subset of the original lifetime requires unsafe code (as it is unsafe).

This guarantee allows libraries to accept a Bound<'a, ThereType> instead of self an rely on the 'a lifetime for unsafe code.

For example ThereType could contain a Transaction<'static> which was transmuted from a Transaction<'a> but due to it needing to use it as a associated type it can't have the lifetime 'a. Still as the method accepts a Bound<'a, ThereType> they can rely on the 'a not having been changed from the original construction and as such know that they can use it after casting/transmuting it to a Transaction<'a>;

Drop

This method will call pre_drop(&mut Bound<'a, Self>) when the wrapper is dropped (which will be followed by a call to Self::drop is Self impl. drop).

As Self might contain a type with a wrong lifetime ('static) and rust will/might have the feature to specialize Drop on 'static. We can not drop that inner value on Drop safely (we can't turn it to "any" shorter lifetime either as it might have been static and as such might need to run the specialized code). So we have to drop it while we still have access to the original

Methods

impl<'a, T> Bound<'a, T> where
    T: BoundExt<'a>, 
[src]

pub unsafe fn new(inner: T) -> Self[src]

Creates a new Bound instance.

Safety

A instance of T has to be bound to a lifetime valid for it as Bound gives this guarantee. So using new with a instance of a type corresponding to a different lifetime then 'a is unsafe behavior.

Also note that using this method can have other safety constraints defined by T as such it should only be used by T to create a Bound wrapper of itself.

Trait Implementations

impl<'a, T> Drop for Bound<'a, T> where
    T: BoundExt<'a>, 
[src]

impl<'a, T> Deref for Bound<'a, T> where
    T: BoundExt<'a>, 
[src]

type Target = T

The resulting type after dereferencing.

Auto Trait Implementations

impl<'a, T> Send for Bound<'a, T> where
    T: Send

impl<'a, T> Sync for Bound<'a, T> where
    T: Sync

impl<'a, T> Unpin for Bound<'a, T> where
    T: Unpin

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

impl<'a, T> RefUnwindSafe for Bound<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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