[−][src]Struct corundum::AssertTxInSafe
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]
impl<T: LooseTxInUnsafe> DerefMut for AssertTxInSafe<T>
[src]
impl<R, F: FnOnce() -> R> FnOnce() for AssertTxInSafe<F> where
F: LooseTxInUnsafe,
[src]
F: LooseTxInUnsafe,
type Output = R
The returned type after the call operator is used.
pub extern "rust-call" fn call_once(self, _args: ()) -> R
[src]
impl<F: Future + LooseTxInUnsafe> Future for AssertTxInSafe<F>
[src]
type Output = F::Output
The type of value produced on completion.
pub fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
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]
T: PSafe,
impl<T> Send for AssertTxInSafe<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for AssertTxInSafe<T> where
T: Sync,
[src]
T: Sync,
impl<T> TxOutSafe for AssertTxInSafe<T> where
T: TxOutSafe,
[src]
T: TxOutSafe,
impl<T> Unpin for AssertTxInSafe<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> VSafe for AssertTxInSafe<T> where
T: VSafe,
[src]
T: VSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F> IntoFuture for F where
F: Future,
[src]
F: Future,
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type Future = F
into_future
)Which kind of future are we turning this into?
pub fn into_future(self) -> <F as IntoFuture>::Future
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,