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 #70

Merged
merged 33 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2d70b70
feat(serde_with_macros): proper handling of `cfg_attr`
sivizius Sep 21, 2024
67326f8
feat(serde_with_macros): proper handling of `cfg_attr` and `schemars`…
jonasbb Oct 1, 2024
c4e6b13
Fix clippy::empty_line_after_doc_comments
jonasbb Oct 1, 2024
efb6b41
Fix clippy::empty_line_after_doc_comments (#785)
jonasbb Oct 1, 2024
352d30c
Update changelog
jonasbb Oct 1, 2024
59f2687
Bump version to 3.10.0
jonasbb Oct 1, 2024
f1b79f2
Bump version to 3.10.0 (#786)
jonasbb Oct 1, 2024
eca5a27
Fix clippy::needless_lifetimes
jonasbb Oct 5, 2024
eb41764
Fix clippy::needless_lifetimes (#789)
jonasbb Oct 5, 2024
a329a52
Bump regex from 1.10.3 to 1.11.0
dependabot[bot] Oct 5, 2024
db290af
Bump regex from 1.10.3 to 1.11.0 (#788)
jonasbb Oct 5, 2024
5d97c6a
Add support for hashbrown v0.15
jonasbb Oct 5, 2024
ef7403d
Update changelog
jonasbb Oct 5, 2024
a58cb33
Add support for hashbrown v0.15 (#790)
jonasbb Oct 5, 2024
bf8cfd4
Bump version to 3.11
jonasbb Oct 5, 2024
bc20634
Bump version to 3.11 (#791)
jonasbb Oct 5, 2024
2b4658c
feat(serde_with): add `with_suffix!`
fgardt Nov 1, 2024
9c793d1
Bump jsonschema to 0.26.1 to allow validation of schema
waltronix Nov 4, 2024
9f86400
Validate generated schemas
waltronix Nov 4, 2024
98bcdb7
Avoid characters in schema name that are invalid as ref
waltronix Nov 4, 2024
2e2d4f0
Generated schemas are not valid when using rust style names in ref (#…
jonasbb Nov 6, 2024
99e30d7
feat(serde_with): add `with_suffix!` (#797)
jonasbb Nov 11, 2024
99f15be
Bump codecov/codecov-action from 4 to 5 in the github-actions group
dependabot[bot] Nov 16, 2024
d57f3ab
Bump codecov/codecov-action from 4 to 5 in the github-actions group (…
jonasbb Nov 17, 2024
644649c
Do not run tarpaulin on serde_with_macros
jonasbb Dec 6, 2024
90d8a17
Do not run tarpaulin on serde_with_macros (#805)
jonasbb Dec 6, 2024
39571b2
Ignore RUSTSEC-2024-0402 as borsh serialization is not used here
jonasbb Dec 6, 2024
e1bf368
Ignore RUSTSEC-2024-0402 as borsh serialization is not used here (#806)
jonasbb Dec 6, 2024
0c26b2e
Reformat all cargo.toml
nyurik Nov 28, 2024
16b51a7
Reformat all cargo.toml (#803)
jonasbb Dec 6, 2024
9a08c67
Update url
jonasbb Dec 12, 2024
d8c7e33
Update some dev dependencies
jonasbb Dec 13, 2024
abb13ca
Update url (#808)
jonasbb Dec 13, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: "Check no_std+alloc (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo check --package serde_with --no-default-features --features=alloc --target thumbv7em-none-eabihf
- name: "Check no_std+alloc+optional (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo check --package serde_with --no-default-features --features=alloc,base64,chrono_0_4,hashbrown_0_14,hex,indexmap_1,indexmap_2,json,time_0_3 --target thumbv7em-none-eabihf
run: cargo check --package serde_with --no-default-features --features=alloc,base64,chrono_0_4,hashbrown_0_14,hashbrown_0_15,hex,indexmap_1,indexmap_2,json,time_0_3 --target thumbv7em-none-eabihf

# The tests are split into build and run steps, to see the time impact of each
# cargo test --all-targets does NOT run doctests
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions serde_with/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

* Add support for `hashbrown` v0.15 (#787/#790)

This extends the existing support for `hashbrown` v0.14 to the newly released version.

## [3.10.0] - 2024-10-01

### Added
Expand Down
12 changes: 12 additions & 0 deletions serde_with/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ chrono_0_4 = ["dep:chrono_0_4"]
## It enables the `alloc` feature.
## Some functionality is only available when `std` is enabled too.
hashbrown_0_14 = ["dep:hashbrown_0_14", "alloc"]
## The feature enables `hashbrown::{HashMap, HashSet}` as supported containers.
##
## This pulls in `hashbrown` v0.15 as a dependency.
## It enables the `alloc` feature.
## Some functionality is only available when `std` is enabled too.
hashbrown_0_15 = ["dep:hashbrown_0_15", "alloc"]
## The feature enables serializing data in hex format.
##
## This pulls in `hex` as a dependency.
Expand Down Expand Up @@ -126,6 +132,7 @@ chrono_0_4 = {package = "chrono", version = "0.4.20", optional = true, default-f
doc-comment = {version = "0.3.3", optional = true}
document-features = {version = "0.2.7", optional = true}
hashbrown_0_14 = {package = "hashbrown", version = "0.14.0", optional = true, default-features = false, features = ["serde"]}
hashbrown_0_15 = {package = "hashbrown", version = "0.15.0", optional = true, default-features = false, features = ["serde"]}
hex = {version = "0.4.3", optional = true, default-features = false}
indexmap_1 = {package = "indexmap", version = "1.8", optional = true, default-features = false, features = ["serde-1"]}
indexmap_2 = {package = "indexmap", version = "2.0", optional = true, default-features = false, features = ["serde"]}
Expand Down Expand Up @@ -175,6 +182,11 @@ name = "hashbrown_0_14"
path = "tests/hashbrown_0_14.rs"
required-features = ["hashbrown_0_14", "macros"]

[[test]]
name = "hashbrown_0_15"
path = "tests/hashbrown_0_15.rs"
required-features = ["hashbrown_0_15", "macros"]

[[test]]
name = "indexmap_1"
path = "tests/indexmap_1.rs"
Expand Down
2 changes: 2 additions & 0 deletions serde_with/src/de/duplicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use crate::{
};
#[cfg(feature = "hashbrown_0_14")]
use hashbrown_0_14::{HashMap as HashbrownMap014, HashSet as HashbrownSet014};
#[cfg(feature = "hashbrown_0_15")]
use hashbrown_0_15::{HashMap as HashbrownMap015, HashSet as HashbrownSet015};
#[cfg(feature = "indexmap_1")]
use indexmap_1::{IndexMap, IndexSet};
#[cfg(feature = "indexmap_2")]
Expand Down
13 changes: 13 additions & 0 deletions serde_with/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pub(crate) use self::macros::*;
use crate::{formats::*, prelude::*};
#[cfg(feature = "hashbrown_0_14")]
use hashbrown_0_14::{HashMap as HashbrownMap014, HashSet as HashbrownSet014};
#[cfg(feature = "hashbrown_0_15")]
use hashbrown_0_15::{HashMap as HashbrownMap015, HashSet as HashbrownSet015};
#[cfg(feature = "indexmap_1")]
use indexmap_1::{IndexMap, IndexSet};
#[cfg(feature = "indexmap_2")]
Expand Down Expand Up @@ -32,6 +34,11 @@ pub(crate) mod macros {
HashbrownMap014<K: Eq + Hash, V, S: BuildHasher + Default>,
(|size| HashbrownMap014::with_capacity_and_hasher(size, Default::default()))
);
#[cfg(feature = "hashbrown_0_15")]
$m!(
HashbrownMap015<K: Eq + Hash, V, S: BuildHasher + Default>,
(|size| HashbrownMap015::with_capacity_and_hasher(size, Default::default()))
);
#[cfg(feature = "indexmap_1")]
$m!(
IndexMap<K: Eq + Hash, V, S: BuildHasher + Default>,
Expand Down Expand Up @@ -61,6 +68,12 @@ pub(crate) mod macros {
(|size| HashbrownSet014::with_capacity_and_hasher(size, S::default())),
insert
);
#[cfg(feature = "hashbrown_0_15")]
$m!(
HashbrownSet015<T: Eq + Hash, S: BuildHasher + Default>,
(|size| HashbrownSet015::with_capacity_and_hasher(size, S::default())),
insert
);
#[cfg(feature = "indexmap_1")]
$m!(
IndexSet<T: Eq + Hash, S: BuildHasher + Default>,
Expand Down
2 changes: 2 additions & 0 deletions serde_with/src/de/skip_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use super::impls::macros::foreach_map;
use crate::prelude::*;
#[cfg(feature = "hashbrown_0_14")]
use hashbrown_0_14::HashMap as HashbrownMap014;
#[cfg(feature = "hashbrown_0_15")]
use hashbrown_0_15::HashMap as HashbrownMap015;
#[cfg(feature = "indexmap_1")]
use indexmap_1::IndexMap;
#[cfg(feature = "indexmap_2")]
Expand Down
40 changes: 40 additions & 0 deletions serde_with/src/duplicate_key_impls/error_on_duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ where
}
}

#[cfg(feature = "hashbrown_0_15")]
impl<T, S> PreventDuplicateInsertsSet<T> for hashbrown_0_15::HashSet<T, S>
where
T: Eq + Hash,
S: BuildHasher + Default,
{
#[inline]
fn new(size_hint: Option<usize>) -> Self {
match size_hint {
Some(size) => Self::with_capacity_and_hasher(size, S::default()),
None => Self::with_hasher(S::default()),
}
}

#[inline]
fn insert(&mut self, value: T) -> bool {
self.insert(value)
}
}

#[cfg(feature = "indexmap_1")]
impl<T, S> PreventDuplicateInsertsSet<T> for indexmap_1::IndexSet<T, S>
where
Expand Down Expand Up @@ -149,6 +169,26 @@ where
}
}

#[cfg(feature = "hashbrown_0_15")]
impl<K, V, S> PreventDuplicateInsertsMap<K, V> for hashbrown_0_15::HashMap<K, V, S>
where
K: Eq + Hash,
S: BuildHasher + Default,
{
#[inline]
fn new(size_hint: Option<usize>) -> Self {
match size_hint {
Some(size) => Self::with_capacity_and_hasher(size, S::default()),
None => Self::with_hasher(S::default()),
}
}

#[inline]
fn insert(&mut self, key: K, value: V) -> bool {
self.insert(key, value).is_none()
}
}

#[cfg(feature = "indexmap_1")]
impl<K, V, S> PreventDuplicateInsertsMap<K, V> for indexmap_1::IndexMap<K, V, S>
where
Expand Down
28 changes: 28 additions & 0 deletions serde_with/src/duplicate_key_impls/first_value_wins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ where
}
}

#[cfg(feature = "hashbrown_0_15")]
impl<K, V, S> DuplicateInsertsFirstWinsMap<K, V> for hashbrown_0_15::HashMap<K, V, S>
where
K: Eq + Hash,
S: BuildHasher + Default,
{
#[inline]
fn new(size_hint: Option<usize>) -> Self {
match size_hint {
Some(size) => Self::with_capacity_and_hasher(size, S::default()),
None => Self::with_hasher(S::default()),
}
}

#[inline]
fn insert(&mut self, key: K, value: V) {
use hashbrown_0_15::hash_map::Entry;

match self.entry(key) {
// we want to keep the first value, so do nothing
Entry::Occupied(_) => {}
Entry::Vacant(vacant) => {
vacant.insert(value);
}
}
}
}

#[cfg(feature = "indexmap_1")]
impl<K, V, S> DuplicateInsertsFirstWinsMap<K, V> for indexmap_1::IndexMap<K, V, S>
where
Expand Down
21 changes: 21 additions & 0 deletions serde_with/src/duplicate_key_impls/last_value_wins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ where
}
}

#[cfg(feature = "hashbrown_0_15")]
impl<T, S> DuplicateInsertsLastWinsSet<T> for hashbrown_0_15::HashSet<T, S>
where
T: Eq + Hash,
S: BuildHasher + Default,
{
#[inline]
fn new(size_hint: Option<usize>) -> Self {
match size_hint {
Some(size) => Self::with_capacity_and_hasher(size, S::default()),
None => Self::with_hasher(S::default()),
}
}

#[inline]
fn replace(&mut self, value: T) {
// Hashset already fulfils the contract
self.replace(value);
}
}

#[cfg(feature = "indexmap_1")]
impl<T, S> DuplicateInsertsLastWinsSet<T> for indexmap_1::IndexSet<T, S>
where
Expand Down
2 changes: 2 additions & 0 deletions serde_with/src/schemars_0_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ map_first_last_wins_schema!(BTreeMap<K, V>);
map_first_last_wins_schema!(=> S HashMap<K, V, S>);
#[cfg(feature = "hashbrown_0_14")]
map_first_last_wins_schema!(=> S hashbrown_0_14::HashMap<K, V, S>);
#[cfg(feature = "hashbrown_0_15")]
map_first_last_wins_schema!(=> S hashbrown_0_15::HashMap<K, V, S>);
#[cfg(feature = "indexmap_1")]
map_first_last_wins_schema!(=> S indexmap_1::IndexMap<K, V, S>);
#[cfg(feature = "indexmap_2")]
Expand Down
2 changes: 2 additions & 0 deletions serde_with/src/ser/duplicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use super::impls::macros::{foreach_map, foreach_set};
use crate::prelude::*;
#[cfg(feature = "hashbrown_0_14")]
use hashbrown_0_14::{HashMap as HashbrownMap014, HashSet as HashbrownSet014};
#[cfg(feature = "hashbrown_0_15")]
use hashbrown_0_15::{HashMap as HashbrownMap015, HashSet as HashbrownSet015};
#[cfg(feature = "indexmap_1")]
use indexmap_1::{IndexMap, IndexSet};
#[cfg(feature = "indexmap_2")]
Expand Down
6 changes: 6 additions & 0 deletions serde_with/src/ser/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pub(crate) use self::macros::*;
use crate::{formats::Strictness, prelude::*};
#[cfg(feature = "hashbrown_0_14")]
use hashbrown_0_14::{HashMap as HashbrownMap014, HashSet as HashbrownSet014};
#[cfg(feature = "hashbrown_0_15")]
use hashbrown_0_15::{HashMap as HashbrownMap015, HashSet as HashbrownSet015};
#[cfg(feature = "indexmap_1")]
use indexmap_1::{IndexMap, IndexSet};
#[cfg(feature = "indexmap_2")]
Expand Down Expand Up @@ -29,6 +31,8 @@ pub(crate) mod macros {
$m!(HashMap<K, V, H: Sized>);
#[cfg(feature = "hashbrown_0_14")]
$m!(HashbrownMap014<K, V, H: Sized>);
#[cfg(feature = "hashbrown_0_15")]
$m!(HashbrownMap015<K, V, H: Sized>);
#[cfg(feature = "indexmap_1")]
$m!(IndexMap<K, V, H: Sized>);
#[cfg(feature = "indexmap_2")]
Expand All @@ -44,6 +48,8 @@ pub(crate) mod macros {
$m!(HashSet<$T, H: Sized>);
#[cfg(feature = "hashbrown_0_14")]
$m!(HashbrownSet014<$T, H: Sized>);
#[cfg(feature = "hashbrown_0_15")]
$m!(HashbrownSet015<$T, H: Sized>);
#[cfg(feature = "indexmap_1")]
$m!(IndexSet<$T, H: Sized>);
#[cfg(feature = "indexmap_2")]
Expand Down
2 changes: 2 additions & 0 deletions serde_with/src/ser/skip_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use super::impls::macros::foreach_map;
use crate::prelude::*;
#[cfg(feature = "hashbrown_0_14")]
use hashbrown_0_14::HashMap as HashbrownMap014;
#[cfg(feature = "hashbrown_0_15")]
use hashbrown_0_15::HashMap as HashbrownMap015;
#[cfg(feature = "indexmap_1")]
use indexmap_1::IndexMap;
#[cfg(feature = "indexmap_2")]
Expand Down
Loading