1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/// Extract custom runtime context from a dispatcher context.
///
/// # Examples
///
/// ```rust,ignore
/// fn my_call(args: &bool, ctx: &mut TxnContext) -> Fallible<()> {
///     let rctx = runtime_context!(ctx, MyContext);
///
///     // ...
/// }
/// ```
#[macro_export]
macro_rules! runtime_context {
    ($ctx:ident, $type:ty) => {
        $ctx.runtime
            .downcast_mut::<$type>()
            .expect("invalid runtime context")
    };
}