Function bevy::prelude::system_adapter::unwrap
Expand description
System adapter that unwraps the Ok
variant of a Result
.
This is useful for fallible systems that should panic in the case of an error.
There is no equivalent adapter for Option
. Instead, it’s best to provide
an error message and convert to a Result
using ok_or{_else}
.
Examples
Panicking on error
use bevy_ecs::prelude::*;
// Building a new schedule/app...
.add_system_to_stage(
CoreStage::Update,
// Panic if the load system returns an error.
load_save_system.pipe(system_adapter::unwrap)
)
// ...
// A system which may fail irreparably.
fn load_save_system() -> Result<(), std::io::Error> {
let save_file = open_file("my_save.json")?;
dbg!(save_file);
Ok(())
}