path!() { /* proc-macro */ }Expand description
Compile-time validated path construction.
String literals are validated against the path grammar at compile time;
runtime expressions must be PathComponent values.
use structfs_core_store::{path, PathComponent};
let p = path!("users/123/name");
assert_eq!(p.len(), 3);
let name = PathComponent::try_new("alice").unwrap();
let p = path!("users", name, "profile");
assert_eq!(p.to_string(), "users/alice/profile");Build a Path from a mix of literal and runtime components.
- String literals are split on
/and each component is validated at compile time against the StructFS path grammar. - Integer literals become numeric components (array indexing).
- Expressions must be of type
PathComponent(runtime-validated at construction). BareString/&strvalues do not compile; validate them first withPathComponent::try_neworPathComponent::encode.
Returns a structfs_core_store::Path.