macro_rules! ctx {
() => { ... };
( $( $key:ident : $value:expr ),* $(,)? ) => { ... };
}Expand description
Build a Context from key/value pairs. Values may be any type that
implements IntoValue — &str, String, integer types, bool,
Vec<&str>, [&str; N], or an explicit Value::*.
Trailing commas are allowed. Empty ctx! {} produces an empty context.
§Example
use prosaic_core::{ctx, Context, Value};
let c: Context = ctx! {
entity_type: "class",
name: "UserService",
consumer_count: 3,
consumers: ["ProfileComponent", "SettingsComponent", "AdminModule"],
};
assert_eq!(c.get("entity_type"), Some(&Value::String("class".into())));
assert_eq!(c.get("consumer_count"), Some(&Value::Number(3)));