# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

The changes and version numbers apply to both [sscanf_macro] and its wrapper crate [sscanf],
as neither works without the other and versions are always released in parallel.

[sscanf_macro]: https://crates.io/crates/sscanf_macro
[sscanf]: https://crates.io/crates/sscanf

## [0.5.0] - 2026-02-28

### Changed
- Bumped MSRV to `1.88.0` (**BREAKING**).
  - This allows updating all outdated dependencies.
  - This adds several improvements to error messages, like [Span methods] or
    [diagnostic::on_unimplemented][on_unimplemented].
- Changed `sscanf!` return type back to `Option` (**BREAKING**) (sorry).
  - This change was originally made to allow debugging custom types, but the returned error was never really useful,
    and the addition of the derive macro made it useless in not just 99% of use cases like before, but 99.99%.\
    Having a `Result` that should have been an `Option` was adding far too much complexity and multiple pitfalls.
- Completely redesigned the `FromScanf` trait (NOTE: The derive macro still works as before).
- Renamed `sscanf_unescaped` and `format_unescaped` to `sscanf_with_regex` and `format_regex` to be more meaningful (**BREAKING**).
- `format_unescaped` can no longer be written as just a raw string (**BREAKING**).

### Removed
- Removed auto-implementation of `FromScanf` for types implementing `FromStr` (**BREAKING**).
  - This has the benefit that `FromScanf` is now implemented for `&str` and `Cow<str>`, which was previously
    blocked by an "upstream crate might implement FromStr" error.
    - Note: Parsing the types was previously possible through a hack in the `sscanf` macro.
  - This also improves the error message in case `FromScanf` is not implemented.
  - The same functionality can still be achieved with the [`FromScanfSimple`][FromScanfSimple@0.5.0] trait.
- Removed the [`RegexRepresentation`][RegexRepresentation@0.4.4] trait. The `REGEX` constant is now part of
  [`FromScanfSimple`][FromScanfSimple@0.5.0] (**BREAKING**).
- Removed the previously deprecated `FullF32`, `FullF64`, and `HexNumber` (technically breaking, but they have been
  deprecated for 3 years or more).

### Added
- Added a [`FromScanfSimple`][FromScanfSimple@0.5.0] trait to replace the previous combination of
  `FromStr + RegexRepresentation`.
- Added a [`parse`][parse@0.5.0] function to directly parse types that implement `FromScanf`.
- Added a [`Parser`][Parser@0.5.0] type to store parsing metadata in order to make multiple calls to `sscanf` more
  efficient.
- Added [`sscanf_parser`][sscanf_parser@0.5.0] and [`sscanf_parser_with_regex`][sscanf_parser_with_regex@0.5.0]
  macros to generate `Parser`s.

[0.5.0]:                            https://github.com/mich101mich/sscanf/releases/tag/0.5.0
[Span methods]:                     https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.start
[on_unimplemented]:                 https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-diagnosticon_unimplemented-attribute
[RegexRepresentation@0.4.4]:        https://docs.rs/sscanf/0.4.4/sscanf/trait.RegexRepresentation.html
[FromScanfSimple@0.5.0]:            https://docs.rs/sscanf/0.5.0/sscanf/trait.FromScanfSimple.html
[parse@0.5.0]:                      https://docs.rs/sscanf/0.5.0/sscanf/fn.parse.html
[Parser@0.5.0]:                     https://docs.rs/sscanf/0.5.0/sscanf/struct.Parser.html
[sscanf_parser@0.5.0]:              https://docs.rs/sscanf/0.5.0/sscanf/macro.sscanf_parser.html
[sscanf_parser_with_regex@0.5.0]:   https://docs.rs/sscanf/0.5.0/sscanf/macro.sscanf_parser_with_regex.html

## [0.4.4] - 2025-10-30

### Changed
- Removed upper bounds on dependencies
  - This was done to maintain compatibility with older Rust versions (MSRV), but was causing conflicts with
    other crates that depend on the newer versions.
  - Instead there is now a comment in the Cargo.toml on which dependencies to set to a fixed version, which is also
    used for this crate's tests.

[0.4.4]:  https://github.com/mich101mich/sscanf/releases/tag/0.4.4

## [0.4.3] - 2025-03-15

### Changed
- Updated `strsim` dependency to 0.11.1 (See [#12], thanks @musicinmybrain)
- Removed dev-dependency to `thiserror`, as it was only used to simplify a code example
- Added comments to the Cargo.toml for dependencies that can't be updated due to MSRV

[0.4.3]:  https://github.com/mich101mich/sscanf/releases/tag/0.4.3
[#12]:    https://github.com/mich101mich/sscanf/pull/12


## [0.4.2] - 2024-07-21

### Fixed
- Fixed `"unused variable"` in the code generated by the derive macro
- Fixed tests on 32-bit platforms (See [#10])

[0.4.2]:  https://github.com/mich101mich/sscanf/releases/tag/0.4.2
[#10]:    https://github.com/mich101mich/sscanf/issues/10


## [0.4.1] - 2023-05-20

### Added
- More attributes for deriving [`FromScanf`][FromScanf@0.4.1]
  - For Fields: `filter_map` `from`, `try_from`
  - For Structs and Variants: `transparent`
  - For Enums: `autogen` (or `autogenerate`)
- [`FromScanf::from_str`][FromScanf::from_str@0.4.1] as a direct shortcut to do string->type conversion without calling `sscanf`
- This changelog

[0.4.1]:                      https://github.com/mich101mich/sscanf/releases/tag/0.4.1
[FromScanf@0.4.1]:            https://docs.rs/sscanf/0.4.1/sscanf/derive.FromScanf.html
[FromScanf::from_str@0.4.1]:  https://docs.rs/sscanf/0.4.1/sscanf/trait.FromScanf.html#method.from_str


## [0.4.0] - 2022-11-22

### Added
- [`FromScanf`][trait.FromScanf@0.4.0] trait and [`FromScanf`][derive.FromScanf@0.4.0] derive as a new way to add custom types
  - The trait should not be manually implemented. It can be obtained by deriving or as a blanket implementation for
    the previous system of `RegexRepresentation` + `FromStr`

### Changed
- Custom Regex Format Options `{:/.../}` now use a **different escape syntax**
  - Only inner `'/'` characters need to be escaped with `'\'` (in addition to the escaping of `'\'` itself as `'\\'`
    in non-raw strings), making the syntax consistent with similar applications like [JavaScript's regex][JS regex]
- `f32` and `f64` now match against their full syntax in accordance with their [`FromStr` implementation][FromStr_f32].
  This was previously emulated by the [`FullF32`][FullF32@0.3.1] and [`FullF64`][FullF64@0.3.1] types
- The [`Error`][Error@0.4.0] type has been reworked
- Shadow-renamed `scanf` -> `sscanf` to be consistent with the crate name
  - 'Shadow', because the old version is still available to avoid breaking changes, it just no longer shows up in
    the documentation

### Deprecated
- [`FullF32`][FullF32@0.4.0] and [`FullF64`][FullF64@0.4.0], as they no longer provide any benefit

### Removed
- The `chrono` integration

[0.4.0]:                  https://github.com/mich101mich/sscanf/releases/tag/0.4.0
[trait.FromScanf@0.4.0]:  https://docs.rs/sscanf/0.4.0/sscanf/trait.FromScanf.html
[derive.FromScanf@0.4.0]: https://docs.rs/sscanf/0.4.0/sscanf/derive.FromScanf.html
[JS regex]:               https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
[FromStr_f32]:            https://doc.rust-lang.org/std/primitive.f32.#impl-FromStr-for-f32
[FullF32@0.3.1]:          https://docs.rs/sscanf/0.3.1/sscanf/struct.FullF32.html
[FullF64@0.3.1]:          https://docs.rs/sscanf/0.3.1/sscanf/struct.FullF64.html
[Error@0.4.0]:            https://docs.rs/sscanf/0.4.0/sscanf/enum.Error.html
[FullF32@0.4.0]:          https://docs.rs/sscanf/0.4.0/sscanf/struct.FullF32.html
[FullF64@0.4.0]:          https://docs.rs/sscanf/0.4.0/sscanf/struct.FullF64.html


## [0.3.1] - 2022-06-27

### Changed
- `scanf` now uses `Deref<Target=str>` instead of `AsRef<Target=str>` to capture the input
  - This should not break any existing implementations, only allow more possible inputs and provide better compiler
    errors for incorrect inputs

[0.3.1]: https://github.com/mich101mich/sscanf/releases/tag/0.3.1


## [0.3.0] - 2022-06-25

### Changed
- Significant performance improvements
- Custom implementations of [`RegexRepresentation`][RegexRepresentation@0.3.0] and regex format options `{:/.../}` can
  no longer use capture groups (unescaped round brackets `(...)`). Existing groups have to be made non-capturing by
  adding `?:` like this: `(?:...)`

[0.3.0]:                      https://github.com/mich101mich/sscanf/releases/tag/0.3.0
[RegexRepresentation@0.3.0]:  https://docs.rs/sscanf/0.3.0/sscanf/trait.RegexRepresentation.html


## [0.2.2] - 2022-06-25

### Changed
- Backport of some improvements from the [0.3.0](#030---2022-06-25) release above, but without the breaking changes
  to stay semver-compliant

[0.2.2]: https://github.com/mich101mich/sscanf/releases/tag/0.2.2


## [0.2.1] - 2022-02-03

### Added
- Ability to use `str` as the type to match. This will match any text, similar to using `String`, but will borrow from
  the input string instead of cloning the substring
  - Using this requires that the input lives longer than the return value

[0.2.1]: https://github.com/mich101mich/sscanf/releases/tag/0.2.1


## [0.2.0] - 2022-02-02

### Added
- Ability to place the type directly in the corresponding placeholder
  - Imitates the [Rust format!() behavior since 1.58][std_format_syntax]

### Changed
- Format Options have to be prefixed with a `:` now to separate them from types!
  - `scanf!(input, "{x}", i32)` is now written as either `scanf!(input, "{:x}", i32)` or `scanf!(input, "{i32:x}")`
- Return type of `scanf!` is now a `Result` instead of `Option`, returning the [`Error`][Error@0.2.0] type if the parsing fails
  - New Signature: `scanf!(<input>, "<format>", <types>...) -> Result<(<types>...), Error>`

[0.2.0]:              https://github.com/mich101mich/sscanf/releases/tag/0.2.0
[std_format_syntax]:  https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html#captured-identifiers-in-format-strings
[Error@0.2.0]:        https://docs.rs/sscanf/0.2.0/sscanf/enum.Error.html


## [0.1.4] - 2021-12-01

### Added
- New format option for supplying a custom regex
  - Syntax: A regex surrounded by `/` on both sides: `{/.../}`

[0.1.4]: https://github.com/mich101mich/sscanf/releases/tag/0.1.4


## [0.1.3] - 2021-09-12

### Added
- Format Options
  - Placing `x`, `o`, or `b` inside of a `{}` placeholder like: `{x}` causes the number to be parsed from a
    hex/octal/binary string with optional prefix like `0x`
  - Using `r2` - `r36` in the placeholder allows parsing number types from any base between 2 and 36
- [`chrono`][chrono] integration
  - Ability to parse from `chrono`'s types by specifying a [date format][chrono_format] inside of the `{}` placeholders
  - Requires activating the `chrono` feature of `sscanf` in your `Cargo.toml`

### Deprecated
- [`HexNumber`][HexNumber@0.1.3]. Use the `{x}` format option instead

[0.1.3]: https://github.com/mich101mich/sscanf/releases/tag/0.1.3
[chrono]: https://crates.io/crates/chrono
[chrono_format]: https://docs.rs/chrono/latest/chrono/format/strftime/index.html
[HexNumber@0.1.3]: https://docs.rs/sscanf/0.1.3/sscanf/struct.HexNumber.html


## [0.1.2] - 2021-05-18

### Changed
- Performance improvements

[0.1.2]: https://github.com/mich101mich/sscanf/releases/tag/0.1.2


## [0.1.1] - 2021-04-15

### Added
- [`HexNumber`][HexNumber@0.1.1], a type to parse integers from hexadecimal strings

[0.1.1]:            https://github.com/mich101mich/sscanf/releases/tag/0.1.1
[HexNumber@0.1.1]:  https://docs.rs/sscanf/0.1.1/sscanf/struct.HexNumber.html


## [0.1.0] - 2021-03-10

Initial Release

### Added
- [`scanf`][scanf@0.1.0] macro to parse an input string according to a format
  - Signature: `scanf!(<input>, "<format>", <types>...) -> Option<(<types>...)>`
- [`scanf_unescaped`][scanf_unescaped@0.1.0] and [`scanf_get_regex`][scanf_get_regex@0.1.0] macros
- [`RegexRepresentation`][RegexRepresentation@0.1.0] trait to allow custom types to be parsed by `scanf`. Note that
  the types also need to implement [`std::str::FromStr`][FromStr]

[0.1.0]:                      https://github.com/mich101mich/sscanf/releases/tag/0.1.0
[scanf@0.1.0]:                https://docs.rs/sscanf/0.1.0/sscanf/macro.scanf.html
[scanf_unescaped@0.1.0]:      https://docs.rs/sscanf/0.1.0/sscanf/macro.scanf_unescaped.html
[scanf_get_regex@0.1.0]:      https://docs.rs/sscanf/0.1.0/sscanf/macro.scanf_get_regex.html
[RegexRepresentation@0.1.0]:  https://docs.rs/sscanf/0.1.0/sscanf/trait.RegexRepresentation.html
[FromStr]:                    https://doc.rust-lang.org/std/str/trait.FromStr.html
