Skip to content

Commit

Permalink
feat(serde_with): add with_suffix! (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbb authored Nov 11, 2024
2 parents 2e2d4f0 + 2b4658c commit 99e30d7
Show file tree
Hide file tree
Showing 5 changed files with 783 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Some common use cases are:
With `serde_as` large arrays are supported, even if they are nested in other types.
`[bool; 64]`, `Option<[u8; M]>`, and `Box<[[u8; 64]; N]>` are all supported, as [this examples shows](#large-and-const-generic-arrays).
* Skip serializing all empty `Option` types with [`#[skip_serializing_none]`][skip_serializing_none].
* Apply a prefix to each field name of a struct, without changing the de/serialize implementations of the struct using [`with_prefix!`][].
* Apply a prefix / suffix to each field name of a struct, without changing the de/serialize implementations of the struct using [`with_prefix!`][] / [`with_suffix!`][].
* Deserialize a comma separated list like `#hash,#tags,#are,#great` into a `Vec<String>`.
Check the documentation for [`serde_with::StringWithSeparator::<CommaSeparator, T>`][StringWithSeparator].

Expand Down Expand Up @@ -185,6 +185,7 @@ Foo::Bytes {

[`DisplayFromStr`]: https://docs.rs/serde_with/3.11.0/serde_with/struct.DisplayFromStr.html
[`with_prefix!`]: https://docs.rs/serde_with/3.11.0/serde_with/macro.with_prefix.html
[`with_suffix!`]: https://docs.rs/serde_with/3.11.0/serde_with/macro.with_suffix.html
[feature flags]: https://docs.rs/serde_with/3.11.0/serde_with/guide/feature_flags/index.html
[skip_serializing_none]: https://docs.rs/serde_with/3.11.0/serde_with/attr.skip_serializing_none.html
[StringWithSeparator]: https://docs.rs/serde_with/3.11.0/serde_with/struct.StringWithSeparator.html
Expand Down
4 changes: 4 additions & 0 deletions serde_with/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

* Add `with_suffix!` macro, which puts a suffix on every struct field

## [3.11.0] - 2024-10-05

### Added
Expand Down
6 changes: 5 additions & 1 deletion serde_with/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
//! With `serde_as` large arrays are supported, even if they are nested in other types.
//! `[bool; 64]`, `Option<[u8; M]>`, and `Box<[[u8; 64]; N]>` are all supported, as [this examples shows](#large-and-const-generic-arrays).
//! * Skip serializing all empty `Option` types with [`#[skip_serializing_none]`][skip_serializing_none].
//! * Apply a prefix to each field name of a struct, without changing the de/serialize implementations of the struct using [`with_prefix!`][].
//! * Apply a prefix / suffix to each field name of a struct, without changing the de/serialize implementations of the struct using [`with_prefix!`][] / [`with_suffix!`][].
//! * Deserialize a comma separated list like `#hash,#tags,#are,#great` into a `Vec<String>`.
//! Check the documentation for [`serde_with::StringWithSeparator::<CommaSeparator, T>`][StringWithSeparator].
//!
Expand Down Expand Up @@ -259,6 +259,7 @@
//!
//! [`DisplayFromStr`]: https://docs.rs/serde_with/3.11.0/serde_with/struct.DisplayFromStr.html
//! [`with_prefix!`]: https://docs.rs/serde_with/3.11.0/serde_with/macro.with_prefix.html
//! [`with_suffix!`]: https://docs.rs/serde_with/3.11.0/serde_with/macro.with_suffix.html
//! [feature flags]: https://docs.rs/serde_with/3.11.0/serde_with/guide/feature_flags/index.html
//! [skip_serializing_none]: https://docs.rs/serde_with/3.11.0/serde_with/attr.skip_serializing_none.html
//! [StringWithSeparator]: https://docs.rs/serde_with/3.11.0/serde_with/struct.StringWithSeparator.html
Expand Down Expand Up @@ -321,6 +322,9 @@ mod utils;
#[cfg(feature = "std")]
#[doc(hidden)]
pub mod with_prefix;
#[cfg(feature = "std")]
#[doc(hidden)]
pub mod with_suffix;

// Taken from shepmaster/snafu
// Originally licensed as MIT+Apache 2
Expand Down
Loading

0 comments on commit 99e30d7

Please sign in to comment.