path-value

Crates.iopath-value
lib.rspath-value
version0.1.5
sourcesrc
created_at2020-08-21 08:03:57.348121
updated_at2021-07-24 09:22:06.195138
descriptionUniversal type and access property(s) by path
homepage
repositoryhttps://github.com/honsunrise/path-value
max_upload_size
id279072
size140,032
Honsun Zhu (honsunrise)

documentation

https://docs.rs/path-value

README

path-value

Rust Build Status Crate Status Docs Status

path-value is a Rust universal type library used to access property(s) in Value by path.

Quick start

use path_value::Value;

fn main() {
    let mut value_origin = Value::default();

    value_origin.set("/test/bool", true).unwrap();
    value_origin.set("/test/str", "i am string").unwrap();

    println!("{}", value_origin.get::<bool, _, _>("/test/bool").unwrap().unwrap());
    println!("{}", value_origin.get::<String, _, _>("/test/str").unwrap().unwrap());

    println!("\nAfter merge\n");

    let mut value_new = Value::default();

    value_new.set("/test/bool", false).unwrap();
    value_new.set("/test/i32", 1000_i32).unwrap();

    value_origin.merge(value_new).unwrap();

    println!("{}", value_origin.get::<bool, _, _>("/test/bool").unwrap().unwrap());
    println!("{}", value_origin.get::<String, _, _>("/test/str").unwrap().unwrap());
    println!("{}", value_origin.get::<i32, _, _>("/test/i32").unwrap().unwrap());
}

Path grammar

/<path>/<path>[index]

Path Grammar

<path>[index]

represents access to an array of elements

Documentation

License

MIT

Commit count: 7

cargo fmt