Skip to content

Commit

Permalink
BREAKING: restructure serde feature flags
Browse files Browse the repository at this point in the history
Now that bstr has an 'alloc' feature, we need to rethink how we setup
the serde feature flags. Previously, all we had was 'std' and 'no std'.
But now we have 'std', 'alloc only' and 'core only'. In particular, 'no
std' is split into 'alloc only' and 'core only', since neither one bring
in std. To reflect this trichotomy, we rename 'serde1' to 'serde1-std',
and split 'serde1-nostd' into 'serde1-alloc' and 'serde1-core'.

Closes #111
  • Loading branch information
TethysSvensson authored and BurntSushi committed Jul 11, 2022
1 parent 692db65 commit 9eff03a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
run: cargo build --verbose --no-default-features
- if: matrix.build == 'stable'
run: cargo build --verbose --no-default-features --features serde1-nostd
- if: matrix.build == 'stable'
run: cargo build --verbose --no-default-features --features serde1-alloc
- if: matrix.build == 'stable'
run: cargo build --verbose --no-default-features --features alloc
- if: matrix.build == 'stable'
Expand All @@ -74,6 +76,8 @@ jobs:
run: cargo test --verbose --no-default-features
- if: matrix.build == 'stable'
run: cargo test --verbose --no-default-features --features serde1-nostd
- if: matrix.build == 'stable'
run: cargo test --verbose --no-default-features --features serde1-alloc
- if: matrix.build == 'stable'
run: cargo test --verbose --no-default-features --features alloc
- if: matrix.build == 'stable'
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ default = ["std", "unicode"]
std = ["alloc", "memchr/std"]
alloc = []
unicode = ["lazy_static", "regex-automata"]
serde1 = ["std", "serde1-nostd", "serde/std"]
serde1-nostd = ["serde"]
serde1-std = ["std", "serde1-alloc", "serde/std"]
serde1-alloc = ["alloc", "serde1-core", "serde/alloc"]
serde1-core = ["serde"]

[dependencies]
memchr = { version = "2.4.0", default-features = false }
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,16 @@ and Unicode support.
Unicode data compiled into the binary. This includes, but is not limited to,
grapheme/word/sentence segmenters. When this is disabled, basic support such
as UTF-8 decoding is still included.
* `serde1` - **Disabled** by default. Enables implementations of serde traits
for the `BStr` and `BString` types.
* `serde1-nostd` - **Disabled** by default. Enables implementations of serde
* `serde1-std` - **Disabled** by default. Enables implementations of serde
traits for the `BStr` and `BString` types. This also enables the `std` and
`serde/std` features.
* `serde1-alloc` - **Disabled** by default. Enables implementations of serde
traits for the `BStr` and `BString` types, but without enabling `serde/std`.
Instead, `serde/alloc` is enabled. This also enables the `alloc` feature.
* `serde1-core` - **Disabled** by default. Enables implementations of serde
traits for the `BStr` type only, intended for use without `std` or `alloc`.
Generally, you either want `serde1` or `serde1-nostd`, not both.
Generally, you want at most one of `serde1-std`, `serde1-alloc` or
`serde1-core`, but not more than one.


### Minimum Rust version policy
Expand Down
6 changes: 3 additions & 3 deletions src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ mod bstr {
impl_partial_ord!(&'a BStr, String);
}

#[cfg(feature = "serde1-nostd")]
#[cfg(feature = "serde1-core")]
mod bstr_serde {
use core::fmt;

Expand Down Expand Up @@ -742,7 +742,7 @@ mod bstr_serde {
}
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde1-alloc")]
mod bstring_serde {
use core::{cmp, fmt};

Expand Down Expand Up @@ -939,7 +939,7 @@ mod display {
}
}

#[cfg(all(test, feature = "std"))]
#[cfg(all(test, feature = "alloc"))]
mod bstring_arbitrary {
use crate::bstring::BString;

Expand Down

0 comments on commit 9eff03a

Please sign in to comment.