pub struct AssertTxInSafe<T>(pub T);
Expand description

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::heap::*;
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;
    })
};
 
assert_eq!(variable, 7);
// ...

Tuple Fields

0: T

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

The returned type after the call operator is used.

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

Performs the call operation.

The type of value produced on completion.

Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. 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.

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

The output that the future will produce on completion.

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

Which kind of future are we turning this into?

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

Creates a future from a value.

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.