pub fn unwrap<T, E>(_: In<Result<T, E>>) -> Twhere
E: Debug,
👎Deprecated: use
.map(Result::unwrap)
insteadExpand 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...
let mut sched = Schedule::default();
sched.add_systems(
// 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(())
}