1
0
mirror of https://github.com/danog/strum.git synced 2024-11-30 04:28:59 +01:00

Update README and CHANGELOG for new version

This commit is contained in:
Peter Glotfelty 2023-06-17 17:28:04 -07:00
parent 85e2c1692b
commit 2bcf86d0ca
9 changed files with 91 additions and 26 deletions

View File

@ -3,7 +3,7 @@ rust:
- stable - stable
- beta - beta
- nightly - nightly
- 1.32.0 - 1.56.1
matrix: matrix:
allow_failures: allow_failures:
- rust: nightly - rust: nightly

View File

@ -1,5 +1,56 @@
# Changelog # Changelog
## 0.25.0
### Breaking Changes
* [#261](https://github.com/Peternator7/strum/pull/261) Upgrade syn dependency to version 2. This bumps the msrv to
1.56. It's impractical to maintain a package where a core dependency of the ecosystem has a different msrv than this one.
* [270](https://github.com/Peternator7/strum/pull/270) Change the `to_string` behavior when using `default`. Now, when
using `default`, the `display` method will return the display version of the value contained in the enum rather than
the name of the variant.
```rust
#[derive(strum::Display)]
enum Color {
Red,
Blue,
Green,
#[strum(default)]
Other(String)
}
fn main() {
// This used to print "Other", now it prints "Purple"
assert_eq!(Color::Other("Purple".to_string()).to_string(), "Purple");
}
```
If you want the old behavior, you can use the `to_string` attribute to override this behavior. See the PR for an example.
* [268](https://github.com/Peternator7/strum/pull/268) Update the behavior of `EnumCount` to exclude variants that are
`disabled`. This is a breaking change, but the behavior makes it more consistent with other methods.
### New Features
* [#257](https://github.com/Peternator7/strum/pull/257) This PR adds the `EnumIs` macro that automatically implements
`is_{variant_name}` methods for each variant.
```rust
#[derive(EnumIs)]
enum Color {
Red,
Blue,
Green,
}
#[test]
fn simple_test() {
assert!(Color::Red.is_red());
}
```
## 0.24.3 (strum_macros) ## 0.24.3 (strum_macros)
* [#231](https://github.com/Peternator7/strum/pull/231) Add ignore lints for EnumIter not implementing Copy or Debug * [#231](https://github.com/Peternator7/strum/pull/231) Add ignore lints for EnumIter not implementing Copy or Debug

View File

@ -11,7 +11,7 @@ Strum is a set of macros and traits for working with enums and strings easier in
# Compatibility # Compatibility
Strum is currently compatible with versions of rustc >= 1.32.0. Pull Requests that improve compatibility with older Strum is currently compatible with versions of rustc >= 1.56.1. Pull Requests that improve compatibility with older
versions are welcome. The project goal is to support a rust version for at least 2 years after release versions are welcome. The project goal is to support a rust version for at least 2 years after release
and even longer is preferred since this project changes slowly. and even longer is preferred since this project changes slowly.
@ -22,11 +22,11 @@ Cargo.toml. Strum_macros contains the macros needed to derive all the traits in
```toml ```toml
[dependencies] [dependencies]
strum = "0.24" strum = "0.25"
strum_macros = "0.24" strum_macros = "0.25"
# You can also use the "derive" feature, and import the macros directly from "strum" # You can also use the "derive" feature, and import the macros directly from "strum"
# strum = { version = "0.24", features = ["derive"] } # strum = { version = "0.25", features = ["derive"] }
``` ```
# Strum Macros # Strum Macros
@ -68,14 +68,15 @@ information through strings.
Strumming is also a very whimsical motion, much like writing Rust code. Strumming is also a very whimsical motion, much like writing Rust code.
[Macro-Renames]: https://github.com/Peternator7/strum/wiki/Macro-Renames [Macro-Renames]: https://github.com/Peternator7/strum/wiki/Macro-Renames
[EnumString]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumString.html [EnumString]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumString.html
[Display]: https://docs.rs/strum_macros/0.24/strum_macros/derive.Display.html [Display]: https://docs.rs/strum_macros/0.25/strum_macros/derive.Display.html
[AsRefStr]: https://docs.rs/strum_macros/0.24/strum_macros/derive.AsRefStr.html [AsRefStr]: https://docs.rs/strum_macros/0.25/strum_macros/derive.AsRefStr.html
[IntoStaticStr]: https://docs.rs/strum_macros/0.24/strum_macros/derive.IntoStaticStr.html [IntoStaticStr]: https://docs.rs/strum_macros/0.25/strum_macros/derive.IntoStaticStr.html
[EnumVariantNames]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumVariantNames.html [EnumVariantNames]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumVariantNames.html
[EnumIter]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumIter.html [EnumIter]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumIter.html
[EnumProperty]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumProperty.html [EnumIs]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumIs.html
[EnumMessage]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumMessage.html [EnumProperty]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumProperty.html
[EnumDiscriminants]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumDiscriminants.html [EnumMessage]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumMessage.html
[EnumCount]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumCount.html [EnumDiscriminants]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumDiscriminants.html
[FromRepr]: https://docs.rs/strum_macros/0.24/strum_macros/derive.FromRepr.html [EnumCount]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumCount.html
[FromRepr]: https://docs.rs/strum_macros/0.25/strum_macros/derive.FromRepr.html

View File

@ -135,7 +135,7 @@ test_script:
for: for:
- matrix: - matrix:
only: only:
- channel: 1.32.0 - channel: 1.56.1
test_script: test_script:
- cargo test --verbose %cargoflags% - cargo test --verbose %cargoflags%

View File

@ -1,6 +1,6 @@
[package] [package]
name = "strum" name = "strum"
version = "0.24.1" version = "0.25.0"
edition = "2018" edition = "2018"
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"] authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
license = "MIT" license = "MIT"
@ -15,11 +15,11 @@ repository = "https://github.com/Peternator7/strum"
readme = "../README.md" readme = "../README.md"
[dependencies] [dependencies]
strum_macros = { path = "../strum_macros", optional = true, version = "0.24" } strum_macros = { path = "../strum_macros", optional = true, version = "0.25" }
phf = { version = "0.10", features = ["macros"], optional = true } phf = { version = "0.10", features = ["macros"], optional = true }
[dev-dependencies] [dev-dependencies]
strum_macros = { path = "../strum_macros", version = "0.24" } strum_macros = { path = "../strum_macros", version = "0.25" }
[badges] [badges]
travis-ci = { repository = "Peternator7/strum" } travis-ci = { repository = "Peternator7/strum" }

View File

@ -16,11 +16,11 @@
//! //!
//! ```toml //! ```toml
//! [dependencies] //! [dependencies]
//! strum = "0.24" //! strum = "0.25"
//! strum_macros = "0.24" //! strum_macros = "0.25"
//! //!
//! # You can also access strum_macros exports directly through strum using the "derive" feature //! # You can also access strum_macros exports directly through strum using the "derive" feature
//! strum = { version = "0.24", features = ["derive"] } //! strum = { version = "0.25", features = ["derive"] }
//! ``` //! ```
//! //!
@ -101,6 +101,19 @@ pub trait IntoEnumIterator: Sized {
fn iter() -> Self::Iterator; fn iter() -> Self::Iterator;
} }
pub trait VariantIterator: Sized {
type Iterator: Iterator<Item = Self>;
fn iter() -> Self::Iterator;
}
pub trait VariantMetadata {
const VARIANT_COUNT: usize;
const VARIANT_NAMES: &'static [&'static str];
fn variant_name(&self) -> &'static str;
}
/// Associates additional pieces of information with an Enum. This can be /// Associates additional pieces of information with an Enum. This can be
/// autoimplemented by deriving `EnumMessage` and annotating your variants with /// autoimplemented by deriving `EnumMessage` and annotating your variants with
/// `#[strum(message="...")]`. /// `#[strum(message="...")]`.

View File

@ -1,6 +1,6 @@
[package] [package]
name = "strum_macros" name = "strum_macros"
version = "0.24.3" version = "0.25.0"
edition = "2018" edition = "2018"
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"] authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
license = "MIT" license = "MIT"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "strum_nostd_tests" name = "strum_nostd_tests"
version = "0.24.0" version = "0.25.0"
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,6 +1,6 @@
[package] [package]
name = "strum_tests" name = "strum_tests"
version = "0.24.0" version = "0.25.0"
edition = "2018" edition = "2018"
authors = ["Peter Glotfelty <peglotfe@microsoft.com>"] authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]