join

Macro join 

Source
macro_rules! join {
    () => { ... };
    ($single_expression:expr $(,)?) => { ... };
    ($first:expr, $second:expr $(,)?) => { ... };
    ($first:expr, $second:expr, $third:expr $(,)?) => { ... };
    ($first:expr, $second:expr, $third:expr, $fourth:expr $(,)?) => { ... };
    ($first:expr, $second:expr, $third:expr, $fourth:expr, $($rest:expr),+ $(,)?) => { ... };
}
Expand description

Macro to enable writing the equivalent of big sequences of crate::NamespacePath::join and crate::RawNamespacePath::raw_join.

ยงUsage

use nstree::NamespacePath;

#[derive(Debug, Clone, Copy)]
pub enum Application {
    Ssh,
    Cupsd,
    Pacman
}

impl Application {
    const fn ns_string(&self) -> &'static str {
        // ...
    }
}

impl NamespacePath for Application {
    // forwarding impl here...
}

#[derive(Debug, Clone, Copy)]
pub enum Module {
    Logging,
    Watchdog
}

impl Module {
    const fn ns_string(&self) -> &'static str {
        // ...
    }
}

impl NamespacePath for Module {
    // forwarding impl here...
}

let nspath = nstree::join!(
    "manager0",
    Application::Ssh,
    Module::Watchdog,
    String::from("runstate")
).render(Default::default()).to_string();
assert_eq!(nspath, "::manager0::network::ssh::watchdog::runstate");