PackageTrack
Sign in Get early access

litrs

Parse and inspect Rust literals (i.e. tokens in the Rust programming language representing fixed values). Particularly useful for proc macros, but can also be used outside of a proc-macro context.

1.0.0 143M downloads/mo #632 most downloaded on crates.io LukasKalbertodt/litrs

What this package is like to depend on

Last release 10 months ago

20 Oct 2025

Release timing varies

gaps range from 1 weeks to 1.8 years

Nearly every release is documented

notes for 13 of 13 stable releases

Nothing withdrawn

no release was ever pulled

5 years old

13 releases · first in 2021

1 release in the last 12 months

see the full history below

Release timeline

13 releases · May 2021 to Oct 2025
2022 2023 2024 2025 2026
Release Pre-release

Releases

latest 13
  1. 1.0.0 20 Oct 2025
    Release notes

    As announced, this is basically just v0.5. I'm really happy to finally have litrs in v1.x state, as the library was already fit for production usage for a long time. Now the version reflects that.

    • Breaking: Mark Literal as #[non_exhaustive]
    • Document semver guarantees
    Open source →
    Release notes

    As announced, this is basically just v0.5. I'm really happy to finally have litrs in v1.x state, as the library was already fit for production usage for a long time. Now the version reflects that.

    • Breaking: Mark Literal as #[non_exhaustive]
    • Document semver guarantees
    Open source →
  2. 0.5.1 01 Aug 2025
    Release notes
    • Add Literal::raw_input
    Open source →
    Release notes
    • Add Literal::raw_input
    Open source →
  3. 0.5.0 25 Jul 2025
    Release notes

    Note: this is supposed to be essentially a 1.0 release candidate. If there are no problems with this release, it will be released as 1.0 after some time.

    • Breaking Bump MSRC from 1.54 to 1.56
    • Breaking: Remove proc-macro2 from default features
    • Breaking: Make StringLit<String>::into_value return String instead of Cow<'static, str>.
      Make ByteStringLit<String>::into_value return Vec<u8> instead of Cow<'static, [u8]>.
    • Add support for C string literals
    • Limit number of # as delimiter of raw string literals to 256 (to align with spec)
    • Fix license in Cargo.toml to use proper SPDX format (in #19, thanks @atouchet)
    • Fix error span for InvalidStartOfUnicodeEscape errors
    Open source →
    Release notes

    Note: this is supposed to be essentially a 1.0 release candidate. If there are no problems with this release, it will be released as 1.0 after some time.

    • Breaking Bump MSRC from 1.54 to 1.56
    • Breaking: Remove proc-macro2 from default features
    • Breaking: Make StringLit<String>::into_value return String instead of Cow<'static, str>. Make ByteStringLit<String>::into_value return Vec<u8> instead of Cow<'static, [u8]>.
    • Add support for C string literals (also breaking due to new enum variant)
    • Limit number of # as delimiter of raw string literals to 256 (to align with spec)
    • Fix license in Cargo.toml to use proper SPDX format (in #19, thanks @atouchet)
    • Fix error span for InvalidStartOfUnicodeEscape errors
    Open source →
  4. 0.4.2 25 Jul 2025
    Release notes
    • Fix incorrect byte string value with non-ASCII \xHH byte string escapes
      • ByteStringLit::parse(r#"b"\xff""#).unwrap().value() would return [0xc3, 0xbf] instead of [0xff].
    • Remove CR LF normalization to align with spec
      • This is technically a breaking change, but released with a minor version bump as it just aligns with the specification. It is extremely unlikely to affect any real world use case.
    • Fix incorrect error span for out-of-range Unicode escapes
    Open source →
    Release notes
    • Fix incorrect byte string value with non-ASCII \xHH byte string escapes
      • ByteStringLit::parse(r#"b"\xff""#).unwrap().value() would return [0xc3, 0xbf] instead of [0xff].
    • Remove CR LF normalization to align with spec
      • This is technically a breaking change, but released with a minor version bump as it just aligns with the specification. It is extremely unlikely to affect any real world use case.
    • Fix incorrect error span for out-of-range Unicode escapes
    Open source →
  5. 0.4.1 18 Oct 2023
    Release notes
    • Fixed incorrectly labeling 27f32 a float literals in docs.
    • Added hint to integer literal docs about parsing as u128.
    Open source →
    Release notes
    • Fixed incorrectly labeling 27f32 a float literals in docs.
    • Added hint to integer literal docs about parsing as u128.
    Open source →
  6. 0.4.0 05 Mar 2023
    Release notes

    Added

    • Add ability to parse literals with arbitrary suffixes (e.g. "foo"bla or 23px)
    • Add suffix() method to all literal types except BoolLit
    • Add IntegerBase::value
    • Add from_suffix and suffix methods to FloatType and IntegerType
    • Add FromStr and Display impls to FloatType and IntegerType

    Changed

    • Breaking: Mark FloatType and IntegerType as #[non_exhaustive]
    • Breaking: Fix integer parsing for cases like 27f32. Literal::parse
      and IntegerLit::parse will both identify this as an integer literal.
    • Breaking: Fix float parsing by correctly rejecting inputs like 27f32. A
      float literal must have a period OR an exponent part, according to the spec.
      Previously decimal integers were accepted in FloatLit::parse.
    • Improved some parts of the docs

    Removed

    • Breaking: Remove OwnedLiteral and SharedLiteral
    Open source →
    Release notes

    Added

    • Add ability to parse literals with arbitrary suffixes (e.g. "foo"bla or 23px)
    • Add suffix() method to all literal types except BoolLit
    • Add IntegerBase::value
    • Add from_suffix and suffix methods to FloatType and IntegerType
    • Add FromStr and Display impls to FloatType and IntegerType

    Changed

    • Breaking: Mark FloatType and IntegerType as #[non_exhaustive]
    • Breaking: Fix integer parsing for cases like 27f32. Literal::parse and IntegerLit::parse will both identify this as an integer literal.
    • Breaking: Fix float parsing by correctly rejecting inputs like 27f32. A float literal must have a period OR an exponent part, according to the spec. Previously decimal integers were accepted in FloatLit::parse.
    • Improved some parts of the docs

    Removed

    • Breaking: Remove OwnedLiteral and SharedLiteral
    Open source →
  7. 0.3.0 19 Dec 2022
    Release notes

    Breaking

    • Bump MSRV (minimal supported Rust version) to 1.54

    Added

    • Add raw_input and into_raw_input to non-bool *Lit types
    • Add impl From<*Lit> for pm::Literal (for non-bool literals)
    • Add impl From<BoolLit> for pm::Ident

    Fixed

    • Fix link to reference and clarify bool literals (#7)

    Internals

    • Move lots of parsing code into non-generic functions (this hopefully reduces compile times)
    • To implement [into_]raw_input for integer and float literals, their
      internals were changed a bit so that they store the full input string now.
    Open source →
    Release notes

    Breaking

    • Bump MSRV (minimal supported Rust version) to 1.54

    Added

    • Add raw_input and into_raw_input to non-bool *Lit types
    • Add impl From<*Lit> for pm::Literal (for non-bool literals)
    • Add impl From<BoolLit> for pm::Ident

    Fixed

    • Fix link to reference and clarify bool literals (#7)

    Internals

    • Move lots of parsing code into non-generic functions (this hopefully reduces compile times)
    • To implement [into_]raw_input for integer and float literals, their internals were changed a bit so that they store the full input string now.
    Open source →
  8. 0.2.3 09 Jun 2021
    Release notes

    See CHANGELOG.md

    Open source →
    Release notes

    Changed

    • Minor internal code change to bring MSRV from 1.52 to 1.42
    Open source →
  9. 0.2.2 09 Jun 2021
    Release notes

    See CHANGELOG.md

    Open source →
    Release notes

    Changed

    • Fixed (byte) string literal parsing by:
      • Correctly handling "string continue" sequences
      • Correctly converting \n\r into \n
    Open source →
  10. 0.2.1 04 Jun 2021
    Release notes

    See CHANGELOG.md

    Open source →
    Release notes

    Changed

    • Fixed the expected value of the error returned from TryFrom<TokenTree> impls in some cases
    Open source →
  11. 0.2.0 28 May 2021
    Release notes

    Changed

    • Breaking: rename Error to ParseError. That describes its purpose more closely and is particular useful now that other error types exist in the library.

    Removed

    • Breaking: remove proc-macro feature and instead offer the corresponding impls unconditionally. Since the feature didn't enable/disable a dependency (proc-macro is a compiler provided crate) and since apparently it works fine in no_std environments, I dropped this feature. I don't currently see a reason why the corresponding impls should be conditional.

    Added

    • TryFrom<TokenTree> for litrs::Literal impls
    • From<*Lit> for litrs::Literal impls
    • TryFrom<proc_macro[2]::Literal> for *Lit
    • TryFrom<TokenTree> for *Lit
    • InvalidToken error type for all new TryFrom impls
    Open source →
  12. 0.1.1 25 May 2021
    Release notes

    Added

    • From impls to create a Literal from references to proc-macro literal types:
      • From<&proc_macro::Literal>
      • From<&proc_macro2::Literal>
    • Better examples in README and repository
    Open source →
  13. 0.1.0 24 May 2021
    Release notes

    Added

    • Everything
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive