wasm/execution/
assert_validated.rs1use core::fmt::Debug;
4
5pub(crate) trait UnwrapValidatedExt<T> {
6 fn unwrap_validated(self) -> T;
7}
8
9impl<T> UnwrapValidatedExt<T> for Option<T> {
10 fn unwrap_validated(self) -> T {
12 self.expect("Validation guarantees this to be `Some(_)`, but it is `None`")
13 }
14}
15
16impl<T, E: Debug> UnwrapValidatedExt<T> for Result<T, E> {
17 fn unwrap_validated(self) -> T {
19 self.unwrap_or_else(|e| {
20 panic!("Validation guarantees this to be `Ok(_)`, but it is `Err({e:?})`");
21 })
22 }
23}
24
25#[macro_export]
26macro_rules! unreachable_validated {
27 () => {
28 unreachable!("because of prior validation")
29 };
30}