Skip to main content

Crate structfs_path_macro

Crate structfs_path_macro 

Source
Expand description

Proc macro for compile-time validated StructFS paths.

path! validates string literal components against the StructFS path grammar (UAX#31 identifiers or numeric strings) at compile time. Expression arguments must be PathComponent values, which are validated at construction time.

// A single literal path — components validated at compile time
let p = path!("users/123/name");

// Component style — equivalent to the above
let p = path!("users", 123, "name");

// Mixed — literals validated at compile time, expressions must be
// PathComponent (bare String/&str fail to compile)
let name = PathComponent::try_new("alice")?;
let p = path!("users", name, "profile");

// Compile error:
// let p = path!("users/bad-name");
//                ^^^^^^^^^^^^^^^ invalid character '-'

Macros§

path
Build a Path from a mix of literal and runtime components.