Thanks to visit codestin.com
Credit goes to lib.rs

#macro-derive #parser #token #parser-derive #proc-macro

macro token-parser-derive

Derive macros to make structs parsable into tokens

3 releases (breaking)

Uses new Rust 2024

0.3.0 Jan 21, 2026
0.2.0 May 17, 2021
0.1.0 Apr 12, 2021

#10 in #parser-derive

MIT/Apache

6KB
71 lines

Derive macros to automatically implement the Parsable trait from token-parser for tuple structs (unnamed fields).

Supports sequential parsing via parse_list (Parsable derive) or symbol parsing via FromStr (SymbolParsable derive).


Token Parser Derive

Derive macros for the token-parser crate. Automatically implements the Parsable trait for tuple structs.

Features

  • Parsable: Parses unnamed fields sequentially using Parsable::parse_next.
  • SymbolParsable: Parses unnamed fields (single-field recommended) using FromStr from a symbol string.

Usage

use token_parser::Parsable;
use token_parser_derive::{Parsable, SymbolParsable};

// Sequential parsing from parser
#[derive(Parsable)]
struct Point(f32, f32);

// Symbol parsing (e.g., numbers/strings)
#[derive(SymbolParsable)]
struct Token(String);

Dependencies

~135–520KB
~12K SLoC