Skip to main content

path_map

Macro path_map 

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

Construct a PathMap from key-value pairs.

This macro provides ergonomic syntax for creating PathMap values for conditional edge routing. Each entry maps a router return value to a target node name.

Both string literals and owned String values are supported.

§Syntax

use juncture_core::path_map;

let pm = path_map! {
    "approve" => "publish",
    "reject"  => "archive",
};

A trailing comma is optional but recommended for consistency.

§Examples

use juncture_core::path_map;

// With string literals
let pm = path_map! {
    "a" => "x",
    "b" => "y",
    "c" => "z",
};
assert_eq!(pm.len(), 3);

// With owned String values
let key = String::from("route");
let val = String::from("target");
let pm = path_map! {
    key => val,
};
assert_eq!(pm.get("route"), Some(&"target".to_string()));