Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from jonasbb:master #68

Merged
merged 27 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
83b3875
Bump time to v0.3.36 to include nightly fix
jonasbb May 22, 2024
55db6fc
Bump MSRV for time dependency
jonasbb May 22, 2024
c348ea4
Bump time to 0.3.36 for nightly compatability (#750)
jonasbb May 22, 2024
242286c
Enable the `unexpected_cfgs` lint now that it can be configured via `…
jonasbb May 22, 2024
9593f93
Enable the `unexpected_cfgs` lint now that it can be configured via `…
jonasbb May 22, 2024
685338f
Replace future deprecated functions from chrono
jonasbb May 22, 2024
729e8d2
Replace future deprecated functions from chrono (#752)
jonasbb May 22, 2024
3ae4424
Fix two clippy issues
jonasbb Jun 8, 2024
f74b460
Fix two clippy issues (#755)
jonasbb Jun 9, 2024
dee706a
Implement JsonSchemaAs for OneOrMany instead of JsonSchema
swlynch99 Jun 28, 2024
c9d9672
Implement JsonSchemaAs for OneOrMany instead of JsonSchema (#760)
jonasbb Jun 30, 2024
e9e7a7e
Bump version to 3.8.2
jonasbb Jun 30, 2024
2274dd1
Bump version to 3.8.2 (#761)
jonasbb Jun 30, 2024
4c8c2db
Make code compile with `schemars_0_8/preserve_order` enabled
jonasbb Jul 3, 2024
19bfe18
Make code compile with `schemars_0_8/preserve_order` enabled (#764)
jonasbb Jul 3, 2024
7de9838
Bump version to v3.8.3
jonasbb Jul 3, 2024
1c4b022
Bump version to v3.8.3 (#765)
jonasbb Jul 3, 2024
4ad4a1b
Fix dead code warning by correcting a typo
jonasbb Jul 12, 2024
f5b2626
Fix dead code warnings in tests
jonasbb Jul 12, 2024
31e9172
Fix dead code warning by correcting a typo (#769)
jonasbb Jul 12, 2024
bf6724d
Move VecSkipError to a separate file, preparing for MapSkipError
johnmave126 Jul 3, 2024
97543d0
Implement MapSkipError, skipping un-deserializable entries.
johnmave126 Jul 3, 2024
17dec11
Add tests to make sure syntax errors are not suppressed.
johnmave126 Jul 4, 2024
aaa0a29
Update serde_with/src/guide/serde_as_transformations.md
johnmave126 Jul 12, 2024
d038657
Implement `MapSkipError`, analogous to `VecSkipError`, but for map-li…
jonasbb Jul 12, 2024
57ad877
Bump version to 3.9.0
jonasbb Jul 14, 2024
c3e489f
Bump version to 3.9.0 (#770)
jonasbb Jul 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions serde_with/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<DisplayFromStr, _>")]
value: BTreeMap<u32, String>,

// Only deserializes entries with a numerical key and a string value, i.e.,
{0 => "v0", 5 => "v5"}
```

## [3.8.3] - 2024-07-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion serde_with/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion serde_with/src/de/skip_error.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
26 changes: 13 additions & 13 deletions serde_with/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<T: ?Sized>(PhantomData<T>);

/// Adapter to convert from `serde_as` to the serde traits.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1289,7 +1289,7 @@ pub struct DurationNanoSecondsWithFrac<
/// [`SystemTime`]: std::time::SystemTime
/// [`chrono::DateTime<Local>`]: ::chrono_0_4::DateTime
/// [`chrono::DateTime<Utc>`]: ::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,
Expand Down Expand Up @@ -1431,7 +1431,7 @@ pub struct TimestampSeconds<
/// [`chrono::DateTime<Local>`]: ::chrono_0_4::DateTime
/// [`chrono::DateTime<Utc>`]: ::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,
Expand Down
1 change: 0 additions & 1 deletion serde_with/src/ser/skip_error.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
4 changes: 4 additions & 0 deletions serde_with_macros/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]

## [3.9.0] - 2024-07-14

No changes.

## [3.8.3] - 2024-07-03

No changes.
Expand Down
10 changes: 5 additions & 5 deletions serde_with_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]

Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading