let occ = occultation(goccults, occid);
if_chain!{
if occ.notches.is_empty();
- if let Some(ilk) = ipc.occilk.as_ref(); // expected, really
+ if let Some(ilk) = want!( Some = ipc.occilk.as_ref() );
let ilk = ilk.borrow();
if let Some(ilk) = ioccults.ilks.get(ilk); // expected, really
if let Ok::<_,IE>(bbox) = ilk.p_occ.bbox_approx(); // expected, really
pub use crate::from_instance_lock_error;
pub use crate::matches_doesnot;
pub use crate::trace_dbg;
+pub use crate::{want, want_let, want_failed_internal};
pub use crate::accounts::loaded_acl::{self, EffectiveACL, LoadedAcl, PermSet};
pub use crate::accounts::*;
trace!("{}", buf);
}
}
+
+}
+
+#[macro_export]
+macro_rules! want_failed_internal {
+ { $variant:ident($binding:pat) = $input:expr, $x:expr, $($d:expr),* } => {
+ InternalLogicError::new({
+ #[allow(unused_mut)]
+ let mut s = format!("wanted {}({}) = {}, but got {:?}",
+ stringify!($variant), stringify!($binding),
+ stringify!($input), $x);
+ $(
+ write!(&mut s, " {}={:?}", stringify!($d), &$d);
+ )*
+ s
+ }).tolerate()
+ }
}
+
+#[macro_export]
+macro_rules! want {
+ { $variant:ident = $input:expr,
+ else ?($($d:expr),*)
+ } => (
+ match $input {
+ $variant(y) => Some(y),
+ x => {
+ want_failed_internal!{ $variant(_)=$input, x, $($d:expr),* }
+ None
+ },
+ };
+ );
+ { $variant:ident = $input:expr } => {
+ want!( $variant = $input,
+ else ?() )
+ };
+}
+
+#[macro_export]
+macro_rules! want_let {
+ { $variant:ident($binding:pat) = $input:expr;
+ else ?($($d:expr),*) $($otherwise:tt)*
+ } => {
+ let $binding = match $input {
+ $variant(y) => y,
+ x => {
+ want_failed_internal!{ $variant($binding)=$input, x, $($d:expr),* }
+ $($otherwise)*
+ },
+ };
+ };
+ { $variant:ident($binding:pat) = $input:expr;
+ else $($otherwise:tt)*
+ } => {
+ want_let!{ $variant($binding) = $input; ?(); $($otherwise:tt)* }
+ };
+}
+
+/*
+#[macro_export]
+macro_rules! want {
+ { $variant:ident($binding:pat) = $input:expr; else $($otherwise:tt)* } => {
+ want
+
+ let $binding = match $input {
+ $variant(y) => y,
+ x => {
+ error!("internal error: wanted {}({}) = {}, but got {:?}",
+ stringify!($variant), stringify!($binding),
+ stringify!($input), x);
+ { $($otherwise)* }
+ },
+ };
+ }
+ { $variant:ident($binding:pat) = $input:expr, $(xdbg:extra),*;
+ else $($otherwise:tt)* }
+ => {
+ let $binding = match $input {
+ $variant(y) => y,
+ x => {
+ error!("internal error: wanted {}({}) = {}, but got {:?}",
+ stringify!($variant), stringify!($binding),
+ stringify!($input), x);
+ { $($otherwise)* }
+ },
+ };
+ }
+}
+*/