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

Add explicit serde feature #436

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ autotests = true
autobenches = true

[package.metadata.docs.rs]
features = ["usize", "u32", "u64", "isize", "i32", "i64", "bigint", "biguint", "rational", "rational32", "rational64", "bigrational", "use_serde"]
features = ["usize", "u32", "u64", "isize", "i32", "i64", "bigint", "biguint", "rational", "rational32", "rational64", "bigrational", "serde"]

[badges]
maintenance = { status = "actively-developed" }
Expand Down Expand Up @@ -71,13 +71,11 @@ f32 = []
f64 = []
si = []
std = ["num-traits/std"]
serde = ["dep:serde", "num-rational?/serde", "num-bigint?/serde", "num-complex?/serde"]
# The try-from feature is deprecated and will be removed in a future release of uom. Functionality
# previously exposed by the feature is now enabled by default.
try-from = []
# The `use_serde` feature exists so that, in the future, other dependency features like num/serde
# can be added. However, num/serde is currently left out because it has not yet been updated to
# Serde 1.0. It is also necessary to name the feature something other than `serde` because of a
# cargo bug: https://github.com/rust-lang/cargo/issues/1286
# Deprecated alias for the serde feature. Will be removed in a future release of uom (v0.37.0+)
use_serde = ["serde"]
# Internal features to include appropriate num-* crates.
rational-support = ["num-rational"]
Expand Down
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ uom = {
"complex32", "complex64", # Complex floating point storage types.
"f32", "f64", # Floating point storage types.
"si", "std", # Built-in SI system and std library support.
"use_serde", # Serde support.
"serde", # Serde support.
]
}
```
Expand All @@ -108,17 +108,9 @@ uom = {
default.
* `std` -- Feature to compile with standard library support. Disabling this feature compiles `uom`
with `no_std`. Enabled by default.
* `use_serde` -- Feature to enable support for serialization and deserialization of quantities
with the [Serde][serde] crate. Disabled by default.

[Serde][serde] support for the `big*` and `rational*` underlying storage types requires manually
enabling the `serde` feature for the `num-rational` and `num-bigint` crates. To do so, you can
add one or both of the following lines to your `Cargo.toml`:

```toml
num-rational = { version = "*", features = ["serde"] }
num-bigint = { version = "*", features = ["serde"] }
```
* `serde` -- Feature to enable support for serialization and deserialization of quantities with the
[Serde][serde] crate. Disabled by default. Replaces the deprecated `use_serde` feature, which will
be removed in a future `uom` release (v0.37.0 or later).

[si]: https://jcgm.bipm.org/vim/en/1.16.html
[serde]: https://serde.rs/
Expand Down
15 changes: 3 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
//! "complex32", "complex64", # Complex floating point storage types.
//! "f32", "f64", # Floating point storage types.
//! "si", "std", # Built-in SI system and std library support.
//! "use_serde", # Serde support.
//! "serde", # Serde support.
Aehmlo marked this conversation as resolved.
Show resolved Hide resolved
//! ]
//! }
//! ```
Expand All @@ -95,17 +95,8 @@
//! default.
//! * `std` -- Feature to compile with standard library support. Disabling this feature compiles
//! `uom` with `no_std`. Enabled by default.
//! * `use_serde` -- Feature to enable support for serialization and deserialization of quantities
//! with the [Serde][serde] crate. Disabled by default.
//!
//! [Serde][serde] support for the `big*` and `rational*` underlying storage types requires
//! manually enabling the `serde` feature for the `num-rational` and `num-bigint` crates. To do
//! so, you can add one or both of the following lines to your `Cargo.toml`:
//!
//! ```toml
//! num-rational = { version = "*", features = ["serde"] }
//! num-bigint = { version = "*", features = ["serde"] }
//! ```
//! * `serde` -- Feature to enable support for serialization and deserialization of quantities with
//! the [Serde][serde] crate. Disabled by default.
//!
//! [si]: https://jcgm.bipm.org/vim/en/1.16.html
//! [serde]: https://serde.rs/
Expand Down
2 changes: 1 addition & 1 deletion tests/edition_check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ uom = { path = "../.." }

[features]
default = []
use_serde = ["uom/use_serde"]
serde = ["uom/serde"]
2 changes: 1 addition & 1 deletion tests/feature_check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ uom = { path = "../.." }

[features]
default = []
use_serde = ["uom/use_serde"]
serde = ["uom/serde"]