Macro no_proto::np_path[][src]

macro_rules! np_path {
    ($str1: tt) => { ... };
}

Generate a path from a string. The path must use dot notation between the path segments.

This requires allocation and will impact performance.

use no_proto::error::NP_Error;
use no_proto::NP_Factory;
use no_proto::np_path;
 
 
assert_eq!(&np_path!("some.crazy.path"), &["some", "crazy", "path"]);
 
let user_factory = NP_Factory::new(r#"
    struct({fields: {
        name: string(),
        todos: list({ of: string() })
    }})
"#)?;
 
let mut user_buffer = user_factory.new_buffer(None);
user_buffer.set(&np_path!("todos.2"), "some todo")?;
user_buffer.set(&np_path!("name"), "Bob Dylan")?;
 
assert_eq!(Some("some todo"), user_buffer.get::<&str>(&["todos", "2"])?);
assert_eq!(Some("Bob Dylan"), user_buffer.get::<&str>(&["name"])?);