From 57ad8778c46c0dd689002930430e3f994af1ebb1 Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Sun, 14 Jul 2024 22:07:06 +0200 Subject: [PATCH] Bump version to 3.9.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- README.md | 14 +++++++------- serde_with/CHANGELOG.md | 23 +++++++++++++++++++++++ serde_with/Cargo.toml | 2 +- serde_with/src/de/skip_error.rs | 1 - serde_with/src/lib.rs | 26 +++++++++++++------------- serde_with/src/ser/skip_error.rs | 1 - serde_with_macros/CHANGELOG.md | 4 ++++ serde_with_macros/src/lib.rs | 10 +++++----- 10 files changed, 56 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 623bb9e0..b40e4038 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -871,7 +871,7 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.3" +version = "3.9.0" dependencies = [ "base64 0.22.1", "chrono", @@ -905,7 +905,7 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.3" +version = "3.9.0" dependencies = [ "darling", "expect-test", diff --git a/Cargo.toml b/Cargo.toml index 240b2910..8ecb14a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/jonasbb/serde_with/" rust-version = "1.67" -version = "3.8.3" +version = "3.9.0" [workspace.metadata.release] consolidate-commits = true diff --git a/README.md b/README.md index 5e926d65..20c2a996 100644 --- a/README.md +++ b/README.md @@ -183,14 +183,14 @@ Foo::Bytes { } ``` -[`DisplayFromStr`]: https://docs.rs/serde_with/3.8.3/serde_with/struct.DisplayFromStr.html -[`with_prefix!`]: https://docs.rs/serde_with/3.8.3/serde_with/macro.with_prefix.html -[feature flags]: https://docs.rs/serde_with/3.8.3/serde_with/guide/feature_flags/index.html -[skip_serializing_none]: https://docs.rs/serde_with/3.8.3/serde_with/attr.skip_serializing_none.html -[StringWithSeparator]: https://docs.rs/serde_with/3.8.3/serde_with/struct.StringWithSeparator.html -[user guide]: https://docs.rs/serde_with/3.8.3/serde_with/guide/index.html +[`DisplayFromStr`]: https://docs.rs/serde_with/3.9.0/serde_with/struct.DisplayFromStr.html +[`with_prefix!`]: https://docs.rs/serde_with/3.9.0/serde_with/macro.with_prefix.html +[feature flags]: https://docs.rs/serde_with/3.9.0/serde_with/guide/feature_flags/index.html +[skip_serializing_none]: https://docs.rs/serde_with/3.9.0/serde_with/attr.skip_serializing_none.html +[StringWithSeparator]: https://docs.rs/serde_with/3.9.0/serde_with/struct.StringWithSeparator.html +[user guide]: https://docs.rs/serde_with/3.9.0/serde_with/guide/index.html [with-annotation]: https://serde.rs/field-attrs.html#with -[as-annotation]: https://docs.rs/serde_with/3.8.3/serde_with/guide/serde_as/index.html +[as-annotation]: https://docs.rs/serde_with/3.9.0/serde_with/guide/serde_as/index.html ## License diff --git a/serde_with/CHANGELOG.md b/serde_with/CHANGELOG.md index e916e68c..22153865 100644 --- a/serde_with/CHANGELOG.md +++ b/serde_with/CHANGELOG.md @@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [3.9.0] - 2024-07-14 + +### Added + +* Deserialize a map` and skip all elements failing to deserialize by @johnmave126 (#763) + + `MapSkipError` acts like a map (`HashMap`/`BTreeMap`), but keys or values that fail to deserialize, like are ignored. + + For formats with heterogeneously typed maps, we can collect only the elements where both key and value are deserializable. + This is also useful in conjunction to `#[serde(flatten)]` to ignore some entries when capturing additional fields. + + ```text + // JSON + "value": {"0": "v0", "5": "v5", "str": "str", "10": 2}, + + // Rust + #[serde_as(as = "MapSkipError")] + value: BTreeMap, + + // Only deserializes entries with a numerical key and a string value, i.e., + {0 => "v0", 5 => "v5"} + ``` + ## [3.8.3] - 2024-07-03 ### Fixed diff --git a/serde_with/Cargo.toml b/serde_with/Cargo.toml index e157814b..c8427997 100644 --- a/serde_with/Cargo.toml +++ b/serde_with/Cargo.toml @@ -133,7 +133,7 @@ schemars_0_8 = {package = "schemars", version = "0.8.16", optional = true, defau serde = {version = "1.0.152", default-features = false} serde_derive = "1.0.152" serde_json = {version = "1.0.45", optional = true, default-features = false} -serde_with_macros = {path = "../serde_with_macros", version = "=3.8.3", optional = true} +serde_with_macros = {path = "../serde_with_macros", version = "=3.9.0", optional = true} time_0_3 = {package = "time", version = "~0.3.36", optional = true, default-features = false} [dev-dependencies] diff --git a/serde_with/src/de/skip_error.rs b/serde_with/src/de/skip_error.rs index e6b915d7..dd7fa1cb 100644 --- a/serde_with/src/de/skip_error.rs +++ b/serde_with/src/de/skip_error.rs @@ -1,6 +1,5 @@ use super::impls::macros::foreach_map; use crate::prelude::*; - #[cfg(feature = "hashbrown_0_14")] use hashbrown_0_14::HashMap as HashbrownMap014; #[cfg(feature = "indexmap_1")] diff --git a/serde_with/src/lib.rs b/serde_with/src/lib.rs index c64f1f6a..2b332667 100644 --- a/serde_with/src/lib.rs +++ b/serde_with/src/lib.rs @@ -21,7 +21,7 @@ )))] // Not needed for 2018 edition and conflicts with `rust_2018_idioms` #![doc(test(no_crate_inject))] -#![doc(html_root_url = "https://docs.rs/serde_with/3.8.3/")] +#![doc(html_root_url = "https://docs.rs/serde_with/3.9.0/")] #![cfg_attr(docsrs, feature(doc_cfg))] #![no_std] @@ -257,14 +257,14 @@ //! # } //! ``` //! -//! [`DisplayFromStr`]: https://docs.rs/serde_with/3.8.3/serde_with/struct.DisplayFromStr.html -//! [`with_prefix!`]: https://docs.rs/serde_with/3.8.3/serde_with/macro.with_prefix.html -//! [feature flags]: https://docs.rs/serde_with/3.8.3/serde_with/guide/feature_flags/index.html -//! [skip_serializing_none]: https://docs.rs/serde_with/3.8.3/serde_with/attr.skip_serializing_none.html -//! [StringWithSeparator]: https://docs.rs/serde_with/3.8.3/serde_with/struct.StringWithSeparator.html -//! [user guide]: https://docs.rs/serde_with/3.8.3/serde_with/guide/index.html +//! [`DisplayFromStr`]: https://docs.rs/serde_with/3.9.0/serde_with/struct.DisplayFromStr.html +//! [`with_prefix!`]: https://docs.rs/serde_with/3.9.0/serde_with/macro.with_prefix.html +//! [feature flags]: https://docs.rs/serde_with/3.9.0/serde_with/guide/feature_flags/index.html +//! [skip_serializing_none]: https://docs.rs/serde_with/3.9.0/serde_with/attr.skip_serializing_none.html +//! [StringWithSeparator]: https://docs.rs/serde_with/3.9.0/serde_with/struct.StringWithSeparator.html +//! [user guide]: https://docs.rs/serde_with/3.9.0/serde_with/guide/index.html //! [with-annotation]: https://serde.rs/field-attrs.html#with -//! [as-annotation]: https://docs.rs/serde_with/3.8.3/serde_with/guide/serde_as/index.html +//! [as-annotation]: https://docs.rs/serde_with/3.9.0/serde_with/guide/serde_as/index.html #[cfg(feature = "alloc")] extern crate alloc; @@ -480,7 +480,7 @@ pub use serde_with_macros::*; /// # } /// ``` /// -/// [serde_as]: https://docs.rs/serde_with/3.8.3/serde_with/attr.serde_as.html +/// [serde_as]: https://docs.rs/serde_with/3.9.0/serde_with/attr.serde_as.html pub struct As(PhantomData); /// Adapter to convert from `serde_as` to the serde traits. @@ -955,7 +955,7 @@ pub struct BytesOrString; /// ``` /// /// [`chrono::Duration`]: ::chrono_0_4::Duration -/// [feature flag]: https://docs.rs/serde_with/3.8.3/serde_with/guide/feature_flags/index.html +/// [feature flag]: https://docs.rs/serde_with/3.9.0/serde_with/guide/feature_flags/index.html pub struct DurationSeconds< FORMAT: formats::Format = u64, STRICTNESS: formats::Strictness = formats::Strict, @@ -1087,7 +1087,7 @@ pub struct DurationSeconds< /// ``` /// /// [`chrono::Duration`]: ::chrono_0_4::Duration -/// [feature flag]: https://docs.rs/serde_with/3.8.3/serde_with/guide/feature_flags/index.html +/// [feature flag]: https://docs.rs/serde_with/3.9.0/serde_with/guide/feature_flags/index.html pub struct DurationSecondsWithFrac< FORMAT: formats::Format = f64, STRICTNESS: formats::Strictness = formats::Strict, @@ -1289,7 +1289,7 @@ pub struct DurationNanoSecondsWithFrac< /// [`SystemTime`]: std::time::SystemTime /// [`chrono::DateTime`]: ::chrono_0_4::DateTime /// [`chrono::DateTime`]: ::chrono_0_4::DateTime -/// [feature flag]: https://docs.rs/serde_with/3.8.3/serde_with/guide/feature_flags/index.html +/// [feature flag]: https://docs.rs/serde_with/3.9.0/serde_with/guide/feature_flags/index.html pub struct TimestampSeconds< FORMAT: formats::Format = i64, STRICTNESS: formats::Strictness = formats::Strict, @@ -1431,7 +1431,7 @@ pub struct TimestampSeconds< /// [`chrono::DateTime`]: ::chrono_0_4::DateTime /// [`chrono::DateTime`]: ::chrono_0_4::DateTime /// [NaiveDateTime]: ::chrono_0_4::NaiveDateTime -/// [feature flag]: https://docs.rs/serde_with/3.8.3/serde_with/guide/feature_flags/index.html +/// [feature flag]: https://docs.rs/serde_with/3.9.0/serde_with/guide/feature_flags/index.html pub struct TimestampSecondsWithFrac< FORMAT: formats::Format = f64, STRICTNESS: formats::Strictness = formats::Strict, diff --git a/serde_with/src/ser/skip_error.rs b/serde_with/src/ser/skip_error.rs index 80066dd2..07c8c99f 100644 --- a/serde_with/src/ser/skip_error.rs +++ b/serde_with/src/ser/skip_error.rs @@ -1,6 +1,5 @@ use super::impls::macros::foreach_map; use crate::prelude::*; - #[cfg(feature = "hashbrown_0_14")] use hashbrown_0_14::HashMap as HashbrownMap014; #[cfg(feature = "indexmap_1")] diff --git a/serde_with_macros/CHANGELOG.md b/serde_with_macros/CHANGELOG.md index 0bb1a347..b95c9d87 100644 --- a/serde_with_macros/CHANGELOG.md +++ b/serde_with_macros/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [3.9.0] - 2024-07-14 + +No changes. + ## [3.8.3] - 2024-07-03 No changes. diff --git a/serde_with_macros/src/lib.rs b/serde_with_macros/src/lib.rs index f2bed4b9..5f4d9983 100644 --- a/serde_with_macros/src/lib.rs +++ b/serde_with_macros/src/lib.rs @@ -20,7 +20,7 @@ )))] // Not needed for 2018 edition and conflicts with `rust_2018_idioms` #![doc(test(no_crate_inject))] -#![doc(html_root_url = "https://docs.rs/serde_with_macros/3.8.3/")] +#![doc(html_root_url = "https://docs.rs/serde_with_macros/3.9.0/")] // Tarpaulin does not work well with proc macros and marks most of the lines as uncovered. #![cfg(not(tarpaulin_include))] @@ -593,8 +593,8 @@ fn field_has_attribute(field: &Field, namespace: &str, name: &str) -> bool { /// It will also work if the relevant derive is behind a `#[cfg_attr]` attribute /// and propagate the `#[cfg_attr]` to the various `#[schemars]` field attributes. /// -/// [`serde_as`]: https://docs.rs/serde_with/3.8.3/serde_with/guide/index.html -/// [re-exporting `serde_as`]: https://docs.rs/serde_with/3.8.3/serde_with/guide/serde_as/index.html#re-exporting-serde_as +/// [`serde_as`]: https://docs.rs/serde_with/3.9.0/serde_with/guide/index.html +/// [re-exporting `serde_as`]: https://docs.rs/serde_with/3.9.0/serde_with/guide/serde_as/index.html#re-exporting-serde_as #[proc_macro_attribute] pub fn serde_as(args: TokenStream, input: TokenStream) -> TokenStream { #[derive(FromMeta)] @@ -1039,7 +1039,7 @@ fn has_type_embedded(type_: &Type, embedded_type: &syn::Ident) -> bool { /// [`Display`]: std::fmt::Display /// [`FromStr`]: std::str::FromStr /// [cargo-toml-rename]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml -/// [serde-as-crate]: https://docs.rs/serde_with/3.8.3/serde_with/guide/serde_as/index.html#re-exporting-serde_as +/// [serde-as-crate]: https://docs.rs/serde_with/3.9.0/serde_with/guide/serde_as/index.html#re-exporting-serde_as /// [serde-crate]: https://serde.rs/container-attrs.html#crate #[proc_macro_derive(DeserializeFromStr, attributes(serde_with))] pub fn derive_deserialize_fromstr(item: TokenStream) -> TokenStream { @@ -1159,7 +1159,7 @@ fn deserialize_fromstr(mut input: DeriveInput, serde_with_crate_path: Path) -> T /// [`Display`]: std::fmt::Display /// [`FromStr`]: std::str::FromStr /// [cargo-toml-rename]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml -/// [serde-as-crate]: https://docs.rs/serde_with/3.8.3/serde_with/guide/serde_as/index.html#re-exporting-serde_as +/// [serde-as-crate]: https://docs.rs/serde_with/3.9.0/serde_with/guide/serde_as/index.html#re-exporting-serde_as /// [serde-crate]: https://serde.rs/container-attrs.html#crate #[proc_macro_derive(SerializeDisplay, attributes(serde_with))] pub fn derive_serialize_display(item: TokenStream) -> TokenStream {