Registry / utility / from-pest

from-pest

JSON →
library0.3.4rscratesunverified

Convert from a pest grammar to a typed AST, enabling type-safe parsing with pest.

# Cargo.toml [dependencies] from-pest = "0.3.4"
INSTALL
IMPORT
SIG · FROM-PEST
F
from-pest
utilityrustv0.3.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FromPest
✓ use from_pest::FromPest;

Define a pest grammar for numbers and convert parsed pairs into a typed AST struct.

use from_pest::FromPest; use pest::Parser; #[derive(Parser)] #[grammar_inline = "number = { ASCII_DIGIT+ }"] struct MyParser; #[derive(FromPest)] struct Number(String); fn main() { let pairs = MyParser::parse(Rule::number, "42").unwrap(); let number = Number::from_pest(&pairs).unwrap(); println!("Parsed number: {}", number.0); }
Debug
Known issues
gotchaRequires pest and pest_derive as dependencies; grammar must be defined inline or in a file.
fix
Add pest and pest_derive to Cargo.toml and ensure grammar is correct.
affects: >=0.3.0
Upgrade
Version history
0.3.4latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
from-pest — cargo add from-pest · libregistry