All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
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.
0.4.2 2024-07-21
- Fixed
"unused variable"
in the code generated by the derive macro - Fixed tests on 32-bit platforms (#10)
0.4.1 - 2023-05-20
- More attributes for deriving
FromScanf
- For Fields:
filter_map
from
,try_from
- For Structs and Variants:
transparent
- For Enums:
autogen
(orautogenerate
)
- For Fields:
FromScanf::from_str
as a direct shortcut to do string->type conversion without callingsscanf
- This changelog
0.4.0 - 2022-11-22
FromScanf
trait andFromScanf
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
- The trait should not be manually implemented. It can be obtained by deriving or as a blanket
implementation for the previous system of
- 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
- Only inner
f32
andf64
now match against their full syntax in accordance with theirFromStr
implementation. This was previously emulated by theFullF32
andFullF64
types- The
Error
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
- The
chrono
integration
0.3.1 - 2022-06-27
scanf
now usesDeref<Target=str>
instead ofAsRef<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.0 - 2022-06-25
- Significant performance improvements
- Custom implementations of
RegexRepresentation
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.2.2 - 2022-06-25
- Backport of some improvements from the 0.3.0 release above, but without the breaking changes to stay semver-compliant
0.2.1 - 2022-02-03
- Ability to use
str
as the type to match. This will match any text, similar to usingString
, 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.0 - 2022-02-02
- Ability to place the type directly in the corresponding placeholder
- Imitates the Rust format!() behavior since 1.58
- Format Options have to be prefixed with a
:
now to separate them from types!scanf!(input, "{x}", i32)
is now written as eitherscanf!(input, "{:x}", i32)
orscanf!(input, "{i32:x}")
- Return type of
scanf!
is now aResult
instead ofOption
, returning theError
type if the parsing fails- New Signature:
scanf!(<input>, "<format>", <types>...) -> Result<(<types>...), Error>
- New Signature:
0.1.4 - 2021-12-01
- New format option for supplying a custom regex
- Syntax: A regex surrounded by
/
on both sides:{/.../}
- Syntax: A regex surrounded by
0.1.3 - 2021-09-12
- Format Options
- Placing
x
,o
, orb
inside of a{}
placeholder like:{x}
causes the number to be parsed from a hex/octal/binary string with optional prefix like0x
- Using
r2
-r36
in the placeholder allows parsing number types from any base between 2 and 36
- Placing
chrono
integration- Ability to parse from
chrono
's types by specifying a date format inside of the{}
placeholders - Requires activating the
chrono
feature ofsscanf
in yourCargo.toml
- Ability to parse from
HexNumber
. Use the{x}
format option instead
0.1.2 - 2021-05-18
- Performance improvements
0.1.1 - 2021-04-15
HexNumber
, a type to parse integers from hexadecimal strings
0.1.0 - 2021-03-10
Initial Release
scanf
macro to parse an input string according to a format- Signature:
scanf!(<input>, "<format>", <types>...) -> Option<(<types>...)>
- Signature:
scanf_unescaped
andscanf_get_regex
macrosRegexRepresentation
trait to allow custom types to be parsed byscanf
. Note that the types also need to implementstd::str::FromStr