[][src]Macro sealrs::cast

macro_rules! cast {
    ($m:ident , $t:path , $v:ident => $body:expr) => { ... };
}

Casts some Message to the specified type and call user function with this value. Macro may be used as extractor of data from a messages, because he may return values from itself based on the data from a message

Example

// As validator
cast!(msg, responses::MsgResponse, m => {
    assert_eq!(m.data, 99);
});

// As extractor
let data = cast!(msg, responses::MsgResponse, m => {
    m.data;
});

Panic

Macro will case panic, if downcast operation will be failed.