Macro optional_props

Source
macro_rules! optional_props {
    () => { ... };
    ($($key:expr => $value:expr),* $(,)?) => { ... };
}
Expand description

Creates array of pairs which each represent the property key and corresponding value. If a value is None, it will be excluded from the final vector. The vector is preallocated with capacity for all potential items.

ยงExample Use

use helix_db::optional_props;
use helix_db::protocol::value::Value;

let properties: Vec<(String, Value)> = optional_props! {
    "name" => Some("Will"),
    "age" => Some(21),
    "title" => None::<String>,
};

assert_eq!(properties.len(), 2); // "title" is excluded