struct-path for Rust
Library provides a tiny macro implementation to reference Rust struct fields at compile time to represent its string format. This is needed to work with JSON paths, and some others protocols when we still want to rely on the compiler to avoid inconsistent changes.
Features:
- Fast parsing without huge deps;
- Macro produces the code to verify if the specified path really exists;
- Multiple fields/arrays support
- Optional camelCase and PascalCase conversion support;
- Optional delimiter parameter;
- Support for
Iter
-based (Option, Vec, etc) paths using~
delimiter;
Quick start
Cargo.toml:
[]
= "0.2"
Example code:
use *;
// returns "value_str"
let s1: &str = path!;
// returns "value_child.child_value_str"
let s2: &str = path! ;
// returns also "value_child.child_value_str"
let s3: &str = path!;
// returns also "value_child.child_value_str" using trait `Iter`
let s3: &str = path!;
// options, returns "valueChild/childValueStr"
let s4: &str = path! ;
// returns ["value_str", "value_num"]
let arr: = paths!;
Licence
Apache Software License (ASL)
Author
Abdulla Abdurakhmanov