Macro sk_cbor::cbor_map_options[][src]

macro_rules! cbor_map_options {
    ($($key : expr => $value : expr,) +) => { ... };
    ($($key : expr => $value : expr), *) => { ... };
}
Expand description

Creates a CBOR Value of type Map with key-value pairs where values can be Options.

Keys and values are expressions and converted into CBOR Keys and Value Options. The map entry is included iff the Value is not an Option or Option is Some. The syntax for these pairs is key_expression => value_expression,. Duplicate keys will lead to invalid CBOR, i.e. writing these values fails. Keys do not have to be sorted.

Example usage:

let missing_value: Option<bool> = None;
let map = cbor_map_options! {
  0x01 => Some(false),
  "02" => -3,
  "not in map" => missing_value,
};