Skip to main content

first_ok

Macro first_ok 

Source
macro_rules! first_ok {
    ($($operation:expr),+ $(,)?) => { ... };
}
Expand description

Tries operations sequentially until one succeeds.

Returns the first success, or a collection of all errors if all fail.

§Semantics

let result = first_ok!(
    try_cache(),
    try_database(),
    try_fallback(),
).await;

Operations are tried in order. Unlike race!, this is sequential: the second operation only starts after the first fails.