cashmere

cashmere

Rust or else

Preface

This is a simple explanation on how to use the or_else() fn in Rust

Example

let _ = db_data
    .booking_service
    .update_booking_state(BookingState {
        id: booking_id,
        state: state.to_string(),
    })
    .await
    .or_else(|_| return Err(actix_web::error::ErrorUnauthorized("Missing hoster_id")));

References