Skip to content

Commit

Permalink
Add release notes for v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rnag committed Jan 25, 2025
1 parent be4309d commit 5805570
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 27 deletions.
43 changes: 38 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,43 @@ Possible header types:
- `Breaking Changes` for any backwards-incompatible changes.

## [Unreleased]

<!--
### Features
- Added a new struct `MyStruct` with the following methods:
- `my_method()`
- `other_method()`
-->

## v0.5.0 (2025-01-25)

### Features

- **Added support for optional deserialization**:
- New functions were introduced to handle `Option<T>` types during deserialization:
- `as_opt_bool` – Returns `Option<bool>`.
- `as_opt_f64` – Returns `Option<f64>`.
- `as_opt_i64` – Returns `Option<i64>`.
- `as_opt_string` – Returns `Option<String>`.
- `as_opt_u64` – Returns `Option<u64>`.

These functions ensure that `null` values in the JSON input or deserialization errors are correctly deserialized into
`None`,
while valid values will
return the appropriate `Some(T)`.

### Bug Fixes

- Resolved an issue where the existing deserialization functions did not handle `Option<T>` types, only direct types.
Now,
`null` values and errors are deserialized to `None`, making the handling of nulls more consistent with Serde's
standard
behavior.

### Breaking Changes

- No breaking changes introduced in this version.

## v0.4.2 (2023-02-05)

### Bug Fixes
Expand All @@ -32,24 +62,27 @@ Possible header types:
## v0.4.0 (2022-04-18)

### Features

- Add benchmarks to compare performance against `serde_with`.
- Flatten some nested `match` arms into simpler `if` statements.
- Update `as_bool`
- Update to check for a new "truthy" string value of `ON`.
- Add pattern matching to check common *true/false* values **before** converting the string
to uppercase, which should make it overall more efficient.
- Update to check for a new "truthy" string value of `ON`.
- Add pattern matching to check common *true/false* values **before** converting the string
to uppercase, which should make it overall more efficient.
- `serde_this_or_that` is now on par - in terms of performance - with `serde_with`! This is
truly great news.

## v0.3.0 (2022-04-17)

### Breaking Changes

- Remove dependency on the `derive` feature of `serde`
- Add it as an optional feature named `derive` instead.
- Add it as an optional feature named `derive` instead.

### Features

- Replace `utilities` keyword with `this-or-that`, as I want crate to be
searchable when someone types "this or that".
searchable when someone types "this or that".
- Update docs.

## v0.2.0 (2022-04-17)
Expand Down
26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[package]
name = "serde-this-or-that"
version = "0.4.2"
authors = ["Ritvik Nag <rv.kvetch@gmail.com>"]
version = "0.5.0"
authors = ["Ritvik Nag <me@ritviknag.com>"]
description = "Custom deserialization for fields that can be specified as multiple types."
documentation = "https://docs.rs/serde-this-or-that"
repository = "https://github.com/rnag/serde-this-or-that"
readme = "README.md"
keywords = ["serde",
# I would have liked to add the below keyword, but of course
# crates.io has a limit of 5 keywords, so well.. that's that. :\
# "utilities",
# And now surprisingly, I found this keyword to be super useful!
# I'm actually partially shocked that crates.io doesn't use the
# crate name to automagically satisfy user search requests.
"this-or-that",
# Of course, the rest that follow are also pretty solid too.
"deserialization",
"visitor",
"multiple-type"]
# I would have liked to add the below keyword, but of course
# crates.io has a limit of 5 keywords, so well.. that's that. :\
# "utilities",
# And now surprisingly, I found this keyword to be super useful!
# I'm actually partially shocked that crates.io doesn't use the
# crate name to automagically satisfy user search requests.
"this-or-that",
# Of course, the rest that follow are also pretty solid too.
"deserialization",
"visitor",
"multiple-type"]
categories = ["encoding"]
license = "MIT"
edition = "2021"
Expand Down
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This crate works with Cargo with a `Cargo.toml` like:

```toml
[dependencies]
serde-this-or-that = "0.4"
serde-this-or-that = "0.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
```
Expand Down Expand Up @@ -67,15 +67,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

## Exported Functions

- [`as_bool`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_bool.html) / [`as_opt_bool`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_bool.html)
- [`as_f64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_f64.html) / [`as_opt_f64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_f64.html)
- [`as_i64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_i64.html) / [`as_opt_i64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_i64.html)
- [`as_string`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_string.html) / [`as_opt_string`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_string.html)
- [`as_u64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_u64.html) / [`as_opt_u64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_u64.html)
- [`as_bool`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_bool.html) / [
`as_opt_bool`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_bool.html)
- [`as_f64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_f64.html) / [
`as_opt_f64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_f64.html)
- [`as_i64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_i64.html) / [
`as_opt_i64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_i64.html)
- [`as_string`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_string.html) / [
`as_opt_string`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_string.html)
- [`as_u64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_u64.html) / [
`as_opt_u64`](https://docs.rs/serde-this-or-that/latest/serde_this_or_that/fn.as_opt_u64.html)

## Examples

You can check out sample usage of this crate in the [examples/](https://github.com/rnag/serde-this-or-that/tree/main/examples)
You can check out sample usage of this crate in
the [examples/](https://github.com/rnag/serde-this-or-that/tree/main/examples)
folder in the project repo on GitHub.

## Performance
Expand All @@ -94,17 +100,22 @@ The benchmarks live in the [benches/](https://github.com/rnag/serde-this-or-that
folder, and can be run with `cargo bench`.

[`Visitor`]: https://docs.serde.rs/serde/de/trait.Visitor.html

[untagged enum]: https://stackoverflow.com/a/66961340/10237506

[serde_with]: https://docs.rs/serde_with

[`DisplayFromStr`]: https://docs.rs/serde_with/latest/serde_with/struct.DisplayFromStr.html

[`PickFirst`]: https://docs.rs/serde_with/latest/serde_with/struct.PickFirst.html

## Optionals

The extra helper functions that begin with `as_opt`, return an `Option<T>` of the respective data type `T`,
rather than the type `T` itself (see [#4](https://github.com/rnag/serde-this-or-that/issues/4)).

On success, they return a value of `T` wrapped in [`Some`](https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some).
On success, they return a value of `T` wrapped in [
`Some`](https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some).

On error, or when there is a `null` value, or one of an *invalid* data type, the
`as_opt` helper functions return [`None`](https://doc.rust-lang.org/std/option/enum.Option.html#variant.None) instead.
Expand All @@ -117,6 +128,7 @@ to discuss a new feature or change.
Check out the [Contributing][] section in the docs for more info.

[Contributing]: CONTRIBUTING.md

[open an issue]: https://github.com/rnag/serde-this-or-that/issues

## License
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/serde-this-or-that/0.4.2")]
#![doc(html_root_url = "https://docs.rs/serde-this-or-that/0.5.0")]
#![warn(rust_2018_idioms, missing_docs)]
#![deny(warnings, dead_code, unused_imports, unused_mut)]

Expand Down

0 comments on commit 5805570

Please sign in to comment.