[][src]Struct corundum::AssertTxInSafe

pub struct AssertTxInSafe<T: LooseTxInUnsafe>(pub T);

A simple wrapper around a type to assert that it is safe to go in a transaction.

When using transaction it may be the case that some of the closed over variables are not TxInSafe safe. For example if &mut T is captured the compiler will generate a warning indicating that it is not TxInSafe. It may not be the case, however, that this is actually a problem due to the specific usage of transaction if transaction inward safety is specifically taken into account. This wrapper struct is useful for a quick and lightweight annotation that a variable is indeed TxInSafe at the programmer's responsibilities. The Journal object cannot be wrapped by AssertTxInSafe to make sure no inter-pool pointer can be made.

Examples

You may wrap individual captures, as shown below. This ensures that if a new capture is added which is not TxInSafe, you will get a compilation error at that time, which will allow you to consider whether that new capture in fact represent a bug or not.

use corundum::alloc::*;
use corundum::AssertTxInSafe;

let mut variable = 4;
let other_capture = 3;

let result = {
    let mut wrapper = AssertTxInSafe(&mut variable);
    Heap::transaction(move |_| {
        **wrapper += other_capture;
    })
};
// ...

Trait Implementations

impl<T: Debug + LooseTxInUnsafe> Debug for AssertTxInSafe<T>[src]

impl<T: LooseTxInUnsafe> Deref for AssertTxInSafe<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: LooseTxInUnsafe> DerefMut for AssertTxInSafe<T>[src]

impl<R, F: FnOnce() -> R> FnOnce() for AssertTxInSafe<F> where
    F: LooseTxInUnsafe
[src]

type Output = R

The returned type after the call operator is used.

impl<F: Future + LooseTxInUnsafe> Future for AssertTxInSafe<F>[src]

type Output = F::Output

The type of value produced on completion.

impl<T: LooseTxInUnsafe> RefUnwindSafe for AssertTxInSafe<T>[src]

impl<T: LooseTxInUnsafe> TxInSafe for AssertTxInSafe<T>[src]

impl<T: LooseTxInUnsafe> UnwindSafe for AssertTxInSafe<T>[src]

Auto Trait Implementations

impl<T> LooseTxInUnsafe for AssertTxInSafe<T>[src]

impl<T> PSafe for AssertTxInSafe<T> where
    T: PSafe
[src]

impl<T> Send for AssertTxInSafe<T> where
    T: Send
[src]

impl<T> Sync for AssertTxInSafe<T> where
    T: Sync
[src]

impl<T> TxOutSafe for AssertTxInSafe<T> where
    T: TxOutSafe
[src]

impl<T> Unpin for AssertTxInSafe<T> where
    T: Unpin
[src]

impl<T> VSafe for AssertTxInSafe<T> where
    T: VSafe
[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<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

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<V, T> VZip<V> for T where
    V: MultiLane<T>,