lino!() { /* proc-macro */ }Expand description
Procedural macro that provides compile-time validation of Links Notation syntax.
This macro takes Links Notation and validates it at compile time.
At runtime, it calls the parser to construct the LiNo structure, but any syntax errors
are caught during compilation.
§Syntax Options
The macro supports two syntax options:
§1. Direct Syntax (Recommended)
Write Links Notation directly without quotes:
ⓘ
use links_notation::lino;
let result = lino!(papa (lovesMama: loves mama));
let triplet = lino!(papa has car);
let nested = lino!((outer: (inner: value)));§2. String Literal Syntax
Use string literals for complex cases with special characters:
ⓘ
use links_notation::lino;
let result = lino!("papa (lovesMama: loves mama)");
let with_newlines = lino!("line1\nline2");
let with_quotes = lino!(r#"("quoted id": "quoted value")"#);§Examples
ⓘ
use links_notation::lino;
// Direct syntax - cleaner and more native
let result = lino!(papa (lovesMama: loves mama));
// String literal for special characters
let result = lino!("contains special: chars");
// Syntax errors caught at compile time!
// let invalid = lino!((unclosed); // ← Compile error§Benefits
- Compile-time validation: Syntax errors are caught at compile time
- Zero overhead: Simple wrapper around the runtime parser
- Type-safe: Returns fully typed
LiNo<String>structures - Convenient: No need to manually handle parse errors in most cases
- Native syntax: Direct syntax option for cleaner, quote-free code
§Implementation
The macro expands to code that:
- Contains a compile-time validation check
- Calls
parse_lino()at runtime - Unwraps the result (safe because validation passed at compile time)