Macro implicit_clone::imap_deconstruct
source · macro_rules! imap_deconstruct { ($(let { $($key:ident),+ $(,)? } = $map:expr;)*) => { ... }; }
Available on crate feature
map
only.Expand description
A macro to help deconstructs maps inspired by JS.
This macro is an experiment and may change or be entirely deleted before the 1.0 release.
§Usage
use implicit_clone::unsync::*;
use implicit_clone::imap_deconstruct;
let my_imap = [(IString::from("foo"), 1), (IString::from("bar"), 2)]
.into_iter()
.collect::<IMap<IString, u32>>();
imap_deconstruct!(
let { foo, bar, baz } = my_imap;
let { foobarbaz } = my_imap;
);
assert_eq!(foo, Some(1));
assert_eq!(bar, Some(2));
assert_eq!(baz, None);
assert_eq!(foobarbaz, None);