NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #1069 most downloaded on crates.io
Create ridiculously fast Lexers
Latest stable
0.16.1
Last release 9 months ago
30 Jan 2026
Release timing varies
gaps range from 8 days to 10 months
Nearly every release is documented
notes for 10 of 10 stable releases
Nothing withdrawn
no release was ever pulled
4 years old
10 releases · first in 2023
Drag across the ruler to compare, or tap a release to open it.
Remove std usage in generated code by @robot-rover in #521
allow_greedy = true on skips by @robot-rover in #534Full Changelog: v0.16...v0.16.1
Your coding agent can read these notes before it upgrades. Set up the MCP server →
allow_greedy = true on skips by @robot-rover in https://github.com/maciejhirsz/logos/pull/534Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.16...v0.16.1
I'm really happy to announce the release of Logos v0.16!
I'm really happy to announce the release of Logos v0.16!
This version includes many significant changes, especially those contributed by @robot-rover in #491. A big thank you to @robot-rover for the impressive work, and to all the other contributors who made this release possible!
The list of changes is very long and focuses on two main points: fixing many bugs related to backtracking issues and supporting a larger set of regular expressions. All regular expressions should now work, except for a few exceptions. For all the details, please refer to the migration guide. More than ever, the book is the place where you can find help about how to use Logos!
As discussed in v0.13, fixing these bugs required a significant overhaul of Logos's codebase. This was possible at the cost of a slight decrease in performance. We hope to regain the same performance as prior to this release, but in the meantime, users who require optimal performance can continue using v0.15. However, we do not plan on maintaining v0.15 in the future.
If you encounter any bugs related to this release, please submit an issue on GitHub.
package.include in all published crates by @42triangles in https://github.com/maciejhirsz/logos/pull/497LazyLock instead by @QnnOkabayashi in https://github.com/maciejhirsz/logos/pull/498doc_auto_cfg is now doc_cfg by @jeertmans in https://github.com/maciejhirsz/logos/pull/511Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.15.1...v0.16
There should not be any breaking change, but please report any bug you might encounter with this new release.
It has been quite some time since the last release, and this new release contains quite nice new features, especially regarding the derive macro, thanks to the help of many contributors!
There should not be any breaking change, but please report any bug you might encounter with this new release.
Thanks again to all contributors!
cargo msrv and ci by @jeertmans in #469chumsky crate from 0.9.0 to 0.10.0 by @your-diary in #474Full Changelog: v0.15...v0.15.1
It has been quite some time since the last release, and this new release contains quite nice new features, especially regarding the derive macro, thanks to the help of many contributors!
There should not be any breaking change, but please report any bug you might encounter with this new release.
Thanks again to all contributors!
cargo msrv and ci by @jeertmans in https://github.com/maciejhirsz/logos/pull/469chumsky crate from 0.9.0 to 0.10.0 by @your-diary in https://github.com/maciejhirsz/logos/pull/474Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.15...v0.15.1
But it also contains a breaking change:
This is a small release, but it contains two important fixes:
But it also contains a breaking change:
As well as a nice new feature for callback to support returning Result<Skip>!
Moreover, the documentation has received very nice additions.
Many thanks to all the contributors!
Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.14.2...v0.15
Do to a mistake caused when versioning v0.14.3 (which was yanked on crates.io and re-published as v0.15 ), v0.14.2 is re-published under v0.14.4, to a
Important This version was yanked as it bumped the MSRV, and we should have changed the minor (not the patch) part of the version to reflect this.
Important
This version was yanked as it bumped the MSRV, and we should have changed the minor (not the patch) part of the version to reflect this.
This is a small release, but it contains two important fixes:
As well as a nice new feature for callback to support returning Result<Skip>!
Moreover, the documentation has received very nice additions.
Many thanks to all the contributors!
Full Changelog: v0.14.2...v0.14.3
[!IMPORTANT] This version was yanked as it bumped the MSRV, and we should have changed the minor (not the patch) part of the version to reflect this.
This is a small release, but it contains two important fixes:
As well as a nice new feature for callback to support returning Result<Skip>!
Moreover, the documentation has received very nice additions.
Many thanks to all the contributors!
Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.14.2...v0.14.3
chore(book): added link to Rust's reference by @CommanderStorm in #411
forbid_unsafe feature to disable unsafe code by @davidkern in #413Full Changelog: v0.14.1...v0.14.2
forbid_unsafe feature to disable unsafe code by @davidkern in https://github.com/maciejhirsz/logos/pull/413Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.14.1...v0.14.2
refactor: don't use deprecated max_value() method by @LeoDog896 in #404
Lexer::clone leak and UB + tests by @Jakobeha in #390Full Changelog: v0.14...v0.14.1
Lexer::clone leak and UB + tests by @Jakobeha in https://github.com/maciejhirsz/logos/pull/390Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.14...v0.14.1
After months without any new release, 0.14 is finally out!
After months without any new release, 0.14 is finally out!
regex-syntax. This bump actually improves so performances, but only slightly (see below). The documentation about token disambiguation reflects that changes too.Performance changes from #320:
group before changes
----- ------ -------
count_ok/identifiers 1.04 869.2±6.09ns 854.7 MB/sec 1.00 832.9±14.13ns 891.9 MB/sec
count_ok/keywords_operators_and_punctators 1.04 2.6±0.02µs 784.4 MB/sec 1.00 2.5±0.08µs 811.9 MB/sec
count_ok/strings 1.03 597.6±5.73ns 1389.9 MB/sec 1.00 582.6±6.94ns 1425.8 MB/sec
iterate/identifiers 1.05 883.7±23.22ns 840.7 MB/sec 1.00 838.2±12.23ns 886.3 MB/sec
iterate/keywords_operators_and_punctators 1.01 2.6±0.03µs 768.0 MB/sec 1.00 2.6±0.03µs 778.2 MB/sec
iterate/strings 1.02 595.7±7.48ns 1394.5 MB/sec 1.00 583.6±4.39ns 1423.3 MB/sec
The detailed list of patches can be found below, many thanks to all contributors!
As mentioned in 0.13, the author of Logos, @maciejhirsz, is reducing his time on GitHub. A few months ago, I was granted collaborator rights, so I can help to maintain this project by reviewing and merging PRs.
As a result, please tag me, @jeertmans, whenever you need help or else (if I did not give any sign of life for a few days).
From now on, I will be able to publish new versions to crates.io, which I hope to do more frequently than in the past months (or years) of this project.
However, I do not master this project at all, and I welcome any help from the community to make this project grow! I tried to setup a nice working environment, with many tests and guides, to facilitate first time contributors' life!
Debug error type requirement by @shilangyu in https://github.com/maciejhirsz/logos/pull/298Source test for GAT Slice by @kmicklas in https://github.com/maciejhirsz/logos/pull/334Full Changelog: https://github.com/maciejhirsz/logos/compare/v0.13...v0.14
This is a long overdue release that includes a bunch of community provided PRs over the last months:
This is a long overdue release that includes a bunch of community provided PRs over the last months:
Lexer produce a Result<Token, Token::Error> which removes, the need for the #[error] variant. More on that below. (#273)#[logos(crate = path::to::logos)]. (#268){n,m} regex ranges. (#278)SpannedIter now derefs into Lexer, so all Lexer methods are available on it, based on work started by @simvux. (#283, #231)#[logos(skip ...)] attribute to help declare whitespace now that #[error] variant is gone. (#284)syn dependency to 2.0. (#289)In 0.12 interacting with Logos would look like:
use logos::Logos;
#[derive(Logos, Debug, PartialEq)]
enum Token {
#[token("Hello")]
Hello,
#[token("Logos")]
Logos,
// This variant will be emitted if an error is encountered
#[error]
// By convention we also add an attribute to skip whitespace here
#[regex(r"[ \t\n\f]+", logos::skip)]
Error,
}
fn main() {
let mut lex = Token::lexer("Hello Logos");
// `Lexer` is an iterator of `Token`:
assert_eq!(lex.next(), Some(Token::Hello));
assert_eq!(lex.next(), Some(Token::Logos));
assert_eq!(lex.next(), None);
}
In 0.13 the #[error] variant is gone, this is the updated code:
use logos::Logos;
#[derive(Logos, Debug, PartialEq)]
#[logos(skip r"[ \t\n\f]+")] // new way to annotate whitespace
enum Token {
#[token("Hello")]
Hello,
#[token("Logos")]
Logos,
}
fn main() {
let mut lex = Token::lexer("Hello Logos");
// `Lexer` is an iterator of `Result<Token, Token::Error>`:
assert_eq!(lex.next(), Some(Ok(Token::Hello)));
assert_eq!(lex.next(), Some(Ok(Token::Logos)));
assert_eq!(lex.next(), None);
}
By default the associated Token::Error type is just () and holds no data. Originally I've put the #[error] variant on the token because having one flat enum to make a match on seemed like a performance win. Upon some scrutiny however there is no performance cost to matching on Result<Token, ()> vs flat Token due to Rust's ability to optimize enums: if your Token is a simple enumeration with only unit variants (holds no data), and the number of variants doesn't exceed 254, then Result<Token, ()> and Option<Result<Token, ()>> will be represented by a single byte at runtime, and matching for pattern Ok(Token::Hello) in 0.13 should compile to the same code as plain Token::Hello would be in 0.12. See the full discussion in #104.
If you've been using Logos for a while now and you've been fighting with some compile-time bugs, you might have been expecting a bunch of fixes here. Alas, as much as it pains me, there are none. There are two main reasons for this, one being me taking a really long coding break last year well into this year:
This is including public and private repos, I simply wrote no code at all in any capacity, not personal projects, not professional, nothing at all. I really needed that time.
While I'm back and active now, a lot of my time currently is spent on Kobold.
The elephant in the room is that the derive macro is simply unfixable in the current state and requires a complete rewrite. Last time this happened was 3 years ago in 0.10. That rewrite improved things considerably and allowed me to fix numerous outstanding bugs at the time. It took me about two weeks of pretty intense work, and I reckon this time it would be no smaller task.
The main issue is that I've chosen to implement different states of the state machine as separate functions. This made it impossible for the these functions to share common variables on stack, but being really clever I got it to work for the existing test suite. A fatal mistake. Douglas Crockford once said, paraphrasing from memory:
Debugging is harder than writing code. If you write code as cleverly as you possibly can, you are by definition not smart enough to debug it.
The good news is I know how to fix things in a way that basically avoids nearly all pitfalls of current implementation. Instead of functions all states of the state machine should be just unit variants of a single enum with some code in their corresponding match expression arms stuck in a loop.
There are pros and cons to that. When it comes to performance lookup tables that currently use fn pointers would become much smaller (by a factor of 8 for most projects compiled on 64bit architecture), making it much less demanding on CPU cache. On the flip side the generated code would lose automatic inlining of nested function calls, and while that can be done manually as an optimization rolled into the macro itself, it might be a new source of bugs if not done right, and it will almost definitely bloat out the amount of code produced (though it might be sensible to have some feature flags to disable this, particularly for targets like wasm32).
The rewrite in principle should also make it possible to make Logos use ropes such as ropey.
#[regex]Not as much of a nightmare, but something I feel has been a problem for users is relying on a subset of regex syntax, particularly limiting backtracking and look-ahead features for the sake of both simplicity and performance. While it is possible to express pretty much any common programming language syntax necessary with that subset, often enough people find it confusing that you can't just do things like x*?.
What I'd like to do eventually is expand on the #[token] attribute with more DSL-y features, using string literals as means of escaping characters, backwards compatible with current use of the attribute to denote a simple byte sequence. Consider a simple block comment /* ... */, I would like that to be declared as:
#[derive(Logos)]
enum Token {
#[token("/*" ... "*/")]
BlockComment,
// ...
}
The equivalent regex rules for that today would be #[regex(r"\/\*([^*]|\*[^/])*\*\/")]... I think. The fact that I'm not able to write this out of the top of my head without being sure it works should be a testament enough of how clunky it can be. Not to mention this one example kind of breaks one of the main promises of Logos, and that is of making the generated code faster than anything you could write by hand. You do not want to see the codegen for that particular regex.
I've no idea.
In the next few weeks I'd like to get Kobold to 1.0. I also want to get Ramhorns to 1.0 sometime soon, that carte honestly should have been marked 1.0 since last year. I've been guilty of not pushing my crates to 1.0 fast enough, and by not fast enough I mean I've been on noughty versions for most of my projects for years, even though most of them really are production ready and I'm just too much of a chicken to stabilize the API.
With the changes done in 0.13 now I believe the last two issues standing ahead of Logos going 1.0 are the two mentioned above: derive rewrite to fix bugs, and #[token] syntax expansion / phasing out of #[regex] to make the API nicer to use. The former is something I'm best suited to do alone, although the latter could be done by community (though realistically only after the rewrite is done).
If there is a living soul willing to undertake the big rewrite and help push this along faster, do reach out. I can at very least help explain what the hell current codegen is doing. I'd be also happy to give a person or two the ability to review and merge community PRs.
One column per quarter.