$ logos

v0.16.0MAJOR UPDATE

Create ridiculously fast Lexers

Downloads: 25.4M
Recent: 5.5M
Versions: 57
Updated: December 7, 2025

Latest Update Summary

Crate

Name: logos New version: 0.16.0 Release date: 2025-12-07T09:59:40.615393Z

Crate readme

Short description Create ridiculously fast Lexers.

Long description Logos makes it easy to create a Lexer focused on complex problems while generating a faster Lexer than manual implementation. It combines token definitions into a single deterministic state machine and optimizes branches using lookup or jump tables, preventing backtracking inside token definitions and minimizing bounds checking at compile time.

Features • deterministic state machine • lookup tables • jump tables • no backtracking • loop unrolling • batch reads

Code Examples Basic usage

 use logos::Logos;

#[derive(Logos, Debug, PartialEq)]
#[logos(skip r"[ \t\n\f]+")]
enum Token {
    #[token("fast")]
    Fast,

    #[token(".")]
    Period,

    #[regex("[a-zA-Z]+")]
    Text,
}

fn main() {
    let mut lex = Token::lexer("Create ridiculously fast Lexers.");

    assert_eq!(lex.next(), Some(Ok(Token::Text)));
    assert_eq!(lex.span(), 0..6);
    assert_eq!(lex.slice(), "Create");

    assert_eq!(lex.next(), Some(Ok(Token::Text)));
    assert_eq!(lex.span(), 7..19);
    assert_eq!(lex.slice(), "ridiculously");

    assert_eq!(lex.next(), Some(Ok(Token::Fast)));
    assert_eq!(lex.span(), 20..24);
    assert_eq!(lex.slice(), "fast");

    assert_eq!(lex.next(), Some(Ok(Token::Text)));
    assert_eq!(lex.slice(), "Lexers");
    assert_eq!(lex.span(), 25..31);

    assert_eq!(lex.next(), Some(Ok(Token::Period)));
    assert_eq!(lex.span(), 31..32);
    assert_eq!(lex.slice(), ".");

    assert_eq!(lex.next(), None);
}

Linkshttps://logos.maciej.codes/https://crates.io/crates/logoshttps://docs.rs/logoshttps://maciejhirsz.github.io/logos/

https://api.github.com/repos/maciejhirsz/logos/releases/268090488

Release info

Release version:

Release description

Code Examples

Minor update: 0.15.1 → 0.16.0

$ DOWNLOADS TREND

21.5M25.4M

$ VERSION HISTORY

v0.16.0December 7, 2025
v0.15.1August 8, 2025

$ LINKS

$ INSTALL

cargo add logos

Or add to Cargo.toml: logos = "0.16.0"