Skip to content

Commit cc06ba2

Browse files
authored
Merge pull request #680 from jonasbb/cleanups
2 parents 6553804 + 4f1a619 commit cc06ba2

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,31 @@
1414

1515
"cSpell.words": [
1616
"accu",
17+
"alloc",
1718
"binhex",
19+
"Boollike",
1820
"btreemap",
1921
"btreeset",
2022
"chrono",
2123
"clippy",
2224
"codecov",
2325
"concat",
26+
"constgeneric",
2427
"datetime",
2528
"deps",
2629
"Deque",
2730
"deserializable",
2831
"Deserialization",
2932
"Deserializes",
33+
"docsrs",
3034
"elems",
3135
"fromstr",
36+
"hashbrown",
3237
"hasher",
3338
"hashset",
3439
"impls",
3540
"indexmap",
41+
"jsonschema",
3642
"linkedlist",
3743
"markazmierczak",
3844
"Milli",
@@ -41,13 +47,16 @@
4147
"newtype",
4248
"nsecs",
4349
"rustdoc",
50+
"Rustexplorer",
4451
"rustfmt",
4552
"RUSTSEC",
4653
"rustversion",
54+
"schemars",
4755
"serde",
4856
"serde's",
4957
"serializable",
5058
"serializers",
59+
"smoketest",
5160
"struct",
5261
"structs",
5362
"subsec",

serde_with/Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ guide = ["dep:doc-comment", "dep:document-features", "macros", "std"]
5454
#! # Features
5555
#!
5656
#! The following features enable support for types from other crates or enable additional functionality, that requires further dependencies to be pulled in.
57-
#! These features are disabled by default to miniminze the amount of required dependencies.
57+
#! These features are disabled by default to minimize the amount of required dependencies.
5858

5959
## The feature enables serializing data in base64 format.
6060
base64 = ["dep:base64", "alloc"]
@@ -63,11 +63,11 @@ chrono = ["chrono_0_4"]
6363
## The feature enables integration of `chrono` v0.4 specific conversions.
6464
## This includes support for the timestamp and duration types.
6565
## More features are available in combination with `alloc` or `std`.
66-
## The legacy feature name `chrono` is still available for v1 compatability.
66+
## The legacy feature name `chrono` is still available for v1 compatibility.
6767
##
6868
## This pulls in `chrono` v0.4 as a dependency.
6969
chrono_0_4 = ["dep:chrono_0_4"]
70-
## The feature enables `hashbown::{HashMap, HashSet}` as supported containers.
70+
## The feature enables `hashbrown::{HashMap, HashSet}` as supported containers.
7171
##
7272
## This pulls in `hashbrown` v0.14 as a dependency.
7373
## It enables the `alloc` feature.
@@ -82,7 +82,7 @@ hex = ["dep:hex", "alloc"]
8282
indexmap = ["indexmap_1"]
8383
## The feature enables implementations of `indexmap` v1 specific checks.
8484
## This includes support for checking duplicate keys and duplicate values.
85-
## The legacy feature name `indexmap` is still available for v1 compatability.
85+
## The legacy feature name `indexmap` is still available for v1 compatibility.
8686
##
8787
## This pulls in `indexmap` v1 as a dependency.
8888
## It enables the `alloc` feature.
@@ -105,19 +105,19 @@ json = ["dep:serde_json", "alloc"]
105105
##
106106
## This pulls in `serde_with_macros` as a dependency.
107107
macros = ["dep:serde_with_macros"]
108-
## The feature enables integration of `time` v0.3 specific conversions.
109-
## This includes support for the timestamp and duration types.
110-
##
111-
## This pulls in `time` v0.3 as a dependency.
112-
## Some functionality is only available when `alloc` or `std` is enabled too.
113-
time_0_3 = ["dep:time_0_3"]
114108
## This feature enables integration with `schemars` 0.8.
115109
## This makes `#[derive(JsonSchema)]` pick up the correct schema for the type
116110
## used within `#[serde_as(as = ...)]`.
117111
##
118112
## This pulls in `schemars` v0.8 as a dependency. It will also implicitly enable
119113
## the `std` feature as `schemars` is not `#[no_std]`.
120114
schemars_0_8 = ["dep:schemars_0_8", "std", "serde_with_macros?/schemars_0_8"]
115+
## The feature enables integration of `time` v0.3 specific conversions.
116+
## This includes support for the timestamp and duration types.
117+
##
118+
## This pulls in `time` v0.3 as a dependency.
119+
## Some functionality is only available when `alloc` or `std` is enabled too.
120+
time_0_3 = ["dep:time_0_3"]
121121

122122
# When adding new optional dependencies update the documentation in feature-flags.md
123123
[dependencies]
@@ -129,13 +129,13 @@ hashbrown_0_14 = {package = "hashbrown", version = "0.14.0", optional = true, de
129129
hex = {version = "0.4.3", optional = true, default-features = false}
130130
indexmap_1 = {package = "indexmap", version = "1.8", optional = true, default-features = false, features = ["serde-1"]}
131131
indexmap_2 = {package = "indexmap", version = "2.0", optional = true, default-features = false, features = ["serde"]}
132+
schemars_0_8 = {package = "schemars", version = "0.8.16", optional = true, default-features = false}
132133
# The derive feature is needed for the flattened_maybe macro.
133134
# https://github.com/jonasbb/serde_with/blob/eb1965a74a3be073ecd13ec05f02a01bc1c44309/serde_with/src/flatten_maybe.rs#L67
134135
serde = {version = "1.0.152", default-features = false, features = ["derive"] }
135136
serde_json = {version = "1.0.45", optional = true, default-features = false}
136137
serde_with_macros = {path = "../serde_with_macros", version = "=3.4.0", optional = true}
137138
time_0_3 = {package = "time", version = "~0.3.11", optional = true, default-features = false}
138-
schemars_0_8 = {package = "schemars", version = "0.8.16", optional = true, default-features = false}
139139

140140
[dev-dependencies]
141141
expect-test = "1.3.0"

serde_with/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ pub struct As<T: ?Sized>(PhantomData<T>);
504504
/// Adapter to convert from `serde_as` to the serde traits.
505505
///
506506
/// This is the counter-type to [`As`][].
507-
/// It can be used whenever a type implementing [`DeserializeAs`][]/[`SerializeAs`][] is required but the normal `Deserialize`/`Serialize` traits should be used.
507+
/// It can be used whenever a type implementing [`DeserializeAs`]/[`SerializeAs`] is required but the normal [`Deserialize`](::serde::Deserialize)/[`Serialize`](::serde::Serialize) traits should be used.
508508
/// Check [`As`] for an example.
509509
pub struct Same;
510510

@@ -558,7 +558,7 @@ pub struct DisplayFromStr;
558558

559559
/// De/Serialize a [`Option<String>`] type while transforming the empty string to [`None`]
560560
///
561-
/// Convert an [`Option<T>`] from/to string using [`FromStr`] and [`Display`] implementations.
561+
/// Convert an [`Option<T>`] from/to string using [`FromStr`] and [`Display`](::core::fmt::Display) implementations.
562562
/// An empty string is deserialized as [`None`] and a [`None`] vice versa.
563563
///
564564
/// # Examples
@@ -1636,8 +1636,11 @@ pub struct Bytes;
16361636
/// This distinction is not semantically important on the Rust side, thus both forms should deserialize into the same `Vec`.
16371637
///
16381638
/// The `OneOrMany` adapter achieves exactly this use case.
1639-
/// The serialization behavior can be tweaked to either always serialize as a list using `PreferMany` or to serialize as the inner element if possible using `PreferOne`.
1640-
/// By default, `PreferOne` is assumed, which can also be omitted like `OneOrMany<_>`.
1639+
/// The serialization behavior can be tweaked to either always serialize as a list using [`PreferMany`] or to serialize as the inner element if possible using [`PreferOne`].
1640+
/// By default, [`PreferOne`] is assumed, which can also be omitted like `OneOrMany<_>`.
1641+
///
1642+
/// [`PreferMany`]: crate::formats::PreferMany
1643+
/// [`PreferOne`]: crate::formats::PreferOne
16411644
///
16421645
/// # Examples
16431646
///
@@ -1768,7 +1771,7 @@ pub struct PickFirst<T>(PhantomData<T>);
17681771
/// For deserialization the opposite `T: Into<O>` is required.
17691772
/// The `Clone` bound is required since `serialize` operates on a reference but `Into` implementations on references are uncommon.
17701773
///
1771-
/// **Note**: [`TryFromInto`] is the more generalized version of this adapter which uses the [`TryInto`](std::convert::TryInto) trait instead.
1774+
/// **Note**: [`TryFromInto`] is the more generalized version of this adapter which uses the [`TryInto`] trait instead.
17721775
///
17731776
/// # Example
17741777
///
@@ -1849,7 +1852,7 @@ pub struct FromInto<T>(PhantomData<T>);
18491852
/// For serialization `O` needs to be `for<'a> &'a O: Into<T>`.
18501853
/// For deserialization the opposite `T: Into<O>` is required.
18511854
///
1852-
/// **Note**: [`TryFromIntoRef`] is the more generalized version of this adapter which uses the [`TryInto`](std::convert::TryInto) trait instead.
1855+
/// **Note**: [`TryFromIntoRef`] is the more generalized version of this adapter which uses the [`TryInto`] trait instead.
18531856
///
18541857
/// # Example
18551858
///
@@ -2518,10 +2521,9 @@ pub struct SetLastValueWins<T>(PhantomData<T>);
25182521
/// Helper for implementing [`JsonSchema`] on serializers whose output depends
25192522
/// on the type of the concrete field.
25202523
///
2521-
/// It is added implicitly by the [`#[serde_as]`] macro when any `schemars`
2524+
/// It is added implicitly by the [`#[serde_as]`](crate::serde_as) macro when any `schemars`
25222525
/// feature is enabled.
25232526
///
25242527
/// [`JsonSchema`]: ::schemars_0_8::JsonSchema
2525-
/// [`#[serde_as]`]: crate::serde_as
25262528
#[cfg(feature = "schemars_0_8")]
25272529
pub struct Schema<T: ?Sized, TA>(PhantomData<T>, PhantomData<TA>);

serde_with/src/schemars_0_8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub trait JsonSchemaAs<T: ?Sized> {
121121
/// Generates a JSON Schema for this type.
122122
///
123123
/// If the returned schema depends on any [referenceable](JsonSchema::is_referenceable) schemas, then this method will
124-
/// add them to the [`SchemaGenerator`](gen::SchemaGenerator)'s schema definitions.
124+
/// add them to the [`SchemaGenerator`]'s schema definitions.
125125
///
126126
/// This should not return a `$ref` schema.
127127
fn json_schema(gen: &mut SchemaGenerator) -> Schema;

serde_with/src/serde_conv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
/// 2. The type `T` we want to extend with custom behavior.
1313
/// 3. A function or macro taking a `&T` and returning a serializable type.
1414
/// 4. A function or macro taking a deserializable type and returning a `Result<T, E>`.
15-
/// The error type `E` must implement `Display`.
15+
/// The error type `E` must implement [`Display`].
16+
///
17+
/// [`Display`]: std::fmt::Display
1618
///
1719
/// # Example
1820
///

serde_with/src/time_0_3.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! De/Serialization of [time v0.3][time] types
22
//!
33
//! This modules is only available if using the `time_0_3` feature of the crate.
4+
//! No extra types are exposed. Instead it enables support for [`time_0_3::Duration`] together with [`DurationSeconds`] and its variants.
5+
//! The types [`time_0_3::PrimitiveDateTime`] and [`time_0_3::OffsetDateTime`] are supported by [`TimestampSeconds`] and its variants.
6+
//! The well-known format descriptions [`Rfc2822`], [`Rfc3339`] and [`Iso8601`] are supported for [`OffsetDateTime`].
47
//!
58
//! [time]: https://docs.rs/time/0.3/
69

serde_with_macros/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ where
282282
/// The `serialize_always` cannot be used together with a manual `skip_serializing_if` annotations,
283283
/// as these conflict in their meaning. A compile error will be generated if this occurs.
284284
///
285-
/// The `skip_serializing_none` only works if the type is called [`Option`],
286-
/// [`std::option::Option`], or [`core::option::Option`]. Type aliasing an [`Option`] and giving it
285+
/// The `skip_serializing_none` only works if the type is called `Option`,
286+
/// `std::option::Option`, or `core::option::Option`. Type aliasing an [`Option`] and giving it
287287
/// another name, will cause this field to be ignored. This cannot be supported, as proc-macros run
288288
/// before type checking, thus it is not possible to determine if a type alias refers to an
289289
/// [`Option`].
@@ -565,7 +565,7 @@ fn field_has_attribute(field: &Field, namespace: &str, name: &str) -> bool {
565565
/// For example, using `#[serde_as(as = "NoneAsEmptyString")]` on `Option<String>` will not see
566566
/// any change.
567567
///
568-
/// If the automatically applied attribute is undesired, the behavior can be supressed by adding
568+
/// If the automatically applied attribute is undesired, the behavior can be suppressed by adding
569569
/// `#[serde_as(no_default)]`.
570570
571571
/// This can be combined like `#[serde_as(as = "Option<S>", no_default)]`.

0 commit comments

Comments
 (0)