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

Didn't actually change enum variant names in the 0.19 like I meant to.

This commit is contained in:
Peter Glotfelty 🚀 2020-08-02 00:07:38 +00:00
parent 7e5b5e43e8
commit 9508a31f4b
5 changed files with 11 additions and 6 deletions

View File

@ -1,12 +1,15 @@
# Changelog
## 0.20.0
* **Breaking Change**: EnumVariantNames now properly adjusts to the `to_string` and `serialize` attributes.
## 0.19.0
* Fixed a regression using `nth_back`. [#85](https://github.com/Peternator7/strum/pull/85)
* Added repository to Cargo.toml. [#90](https://github.com/Peternator7/strum/pull/90)
* Correctly handle fill align in `Display` impls. [#95](https://github.com/Peternator7/strum/pull/95)
* **Breaking Change**: Use Associated Constant for EnumCount instead of const fn and free constant. [#99](https://github.com/Peternator7/strum/pull/99)
* **Breaking Change**: EnumVariantNames now properly adjusts to the `to_string` and `serialize` attributes.
This behavior is consistent with the other derives.
* **Breaking Change**. `default` and `disabled` should now be written as markers instead of key value pairs.
Here is the old way of adding these attributes to a variant.

View File

@ -1,6 +1,6 @@
[package]
name = "strum"
version = "0.19.0"
version = "0.19.1"
authors = ["Peter Glotfelty <peter.glotfelty@microsoft.com>"]
license = "MIT"

View File

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

View File

@ -1,7 +1,7 @@
use proc_macro2::TokenStream;
use syn;
use crate::helpers::{CaseStyleHelpers, HasTypeProperties};
use crate::helpers::{HasTypeProperties, HasStrumVariantProperties};
pub fn enum_variant_names_inner(ast: &syn::DeriveInput) -> TokenStream {
let name = &ast.ident;
@ -18,7 +18,7 @@ pub fn enum_variant_names_inner(ast: &syn::DeriveInput) -> TokenStream {
let names = variants
.iter()
.map(|v| v.ident.convert_case(type_properties.case_style))
.map(|v| v.get_variant_properties().get_preferred_name(type_properties.case_style))
.collect::<Vec<_>>();
quote! {

View File

@ -11,11 +11,13 @@ fn simple() {
#[derive(EnumVariantNames)]
enum Color {
Red,
#[strum(serialize = "b")]
Blue,
#[strum(to_string="y", serialize="yy")]
Yellow,
}
assert_eq!(Color::VARIANTS, &["Red", "Blue", "Yellow"]);
assert_eq!(Color::VARIANTS, &["Red", "b", "y"]);
}
#[test]