Function stm_core::optionally
[−]
[src]
pub fn optionally<T, F>(tx: &mut Transaction, f: F) -> StmResult<Option<T>> where
F: Fn(&mut Transaction) -> StmResult<T>,
Optionally run a transaction f
. If f
fails with a retry()
, it does
not cancel the whole transaction, but returns None
.
Note that optionally
does not always recover the function, if
inconsistencies where found.
unwrap_or_retry
is the inverse of optionally
.
Example
let x:Option<i32> = atomically(|tx| optionally(tx, |_| retry())); assert_eq!(x, None);