macro_rules! match_object {
    ($obj:ident, ) => { ... };
    ($obj:ident, else => $expr:expr,) => { ... };
    ($obj:ident, $name:ident: $type:ty => $expr:expr, $($rest:tt)*) => { ... };
}
Expand description

Helper macro that makes match-style semantics available for duck typed objects

Example

match_object!{obj,
    string: ObjString => do_something_with_string(string),
    int: ObjInt => do_something_with_int(int),
    else => some_fallback_behavior(obj),
}