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:
parent
85e2c1692b
commit
2bcf86d0ca
@ -3,7 +3,7 @@ rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
- 1.32.0
|
||||
- 1.56.1
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
|
51
CHANGELOG.md
51
CHANGELOG.md
@ -1,5 +1,56 @@
|
||||
# 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)
|
||||
|
||||
* [#231](https://github.com/Peternator7/strum/pull/231) Add ignore lints for EnumIter not implementing Copy or Debug
|
||||
|
31
README.md
31
README.md
@ -11,7 +11,7 @@ Strum is a set of macros and traits for working with enums and strings easier in
|
||||
|
||||
# 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
|
||||
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
|
||||
[dependencies]
|
||||
strum = "0.24"
|
||||
strum_macros = "0.24"
|
||||
strum = "0.25"
|
||||
strum_macros = "0.25"
|
||||
|
||||
# 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
|
||||
@ -68,14 +68,15 @@ information through strings.
|
||||
Strumming is also a very whimsical motion, much like writing Rust code.
|
||||
|
||||
[Macro-Renames]: https://github.com/Peternator7/strum/wiki/Macro-Renames
|
||||
[EnumString]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumString.html
|
||||
[Display]: https://docs.rs/strum_macros/0.24/strum_macros/derive.Display.html
|
||||
[AsRefStr]: https://docs.rs/strum_macros/0.24/strum_macros/derive.AsRefStr.html
|
||||
[IntoStaticStr]: https://docs.rs/strum_macros/0.24/strum_macros/derive.IntoStaticStr.html
|
||||
[EnumVariantNames]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumVariantNames.html
|
||||
[EnumIter]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumIter.html
|
||||
[EnumProperty]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumProperty.html
|
||||
[EnumMessage]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumMessage.html
|
||||
[EnumDiscriminants]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumDiscriminants.html
|
||||
[EnumCount]: https://docs.rs/strum_macros/0.24/strum_macros/derive.EnumCount.html
|
||||
[FromRepr]: https://docs.rs/strum_macros/0.24/strum_macros/derive.FromRepr.html
|
||||
[EnumString]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumString.html
|
||||
[Display]: https://docs.rs/strum_macros/0.25/strum_macros/derive.Display.html
|
||||
[AsRefStr]: https://docs.rs/strum_macros/0.25/strum_macros/derive.AsRefStr.html
|
||||
[IntoStaticStr]: https://docs.rs/strum_macros/0.25/strum_macros/derive.IntoStaticStr.html
|
||||
[EnumVariantNames]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumVariantNames.html
|
||||
[EnumIter]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumIter.html
|
||||
[EnumIs]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumIs.html
|
||||
[EnumProperty]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumProperty.html
|
||||
[EnumMessage]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumMessage.html
|
||||
[EnumDiscriminants]: https://docs.rs/strum_macros/0.25/strum_macros/derive.EnumDiscriminants.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
|
||||
|
@ -135,7 +135,7 @@ test_script:
|
||||
for:
|
||||
- matrix:
|
||||
only:
|
||||
- channel: 1.32.0
|
||||
- channel: 1.56.1
|
||||
|
||||
test_script:
|
||||
- cargo test --verbose %cargoflags%
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strum"
|
||||
version = "0.24.1"
|
||||
version = "0.25.0"
|
||||
edition = "2018"
|
||||
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
|
||||
license = "MIT"
|
||||
@ -15,11 +15,11 @@ repository = "https://github.com/Peternator7/strum"
|
||||
readme = "../README.md"
|
||||
|
||||
[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 }
|
||||
|
||||
[dev-dependencies]
|
||||
strum_macros = { path = "../strum_macros", version = "0.24" }
|
||||
strum_macros = { path = "../strum_macros", version = "0.25" }
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "Peternator7/strum" }
|
||||
|
@ -16,11 +16,11 @@
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! strum = "0.24"
|
||||
//! strum_macros = "0.24"
|
||||
//! strum = "0.25"
|
||||
//! strum_macros = "0.25"
|
||||
//!
|
||||
//! # 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;
|
||||
}
|
||||
|
||||
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
|
||||
/// autoimplemented by deriving `EnumMessage` and annotating your variants with
|
||||
/// `#[strum(message="...")]`.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strum_macros"
|
||||
version = "0.24.3"
|
||||
version = "0.25.0"
|
||||
edition = "2018"
|
||||
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
|
||||
license = "MIT"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strum_nostd_tests"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strum_tests"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
edition = "2018"
|
||||
authors = ["Peter Glotfelty <peglotfe@microsoft.com>"]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user