1
0
mirror of https://github.com/danog/strum.git synced 2024-11-26 20:14:40 +01:00
Commit Graph

181 Commits

Author SHA1 Message Date
Peter Glotfelty
96c63e9f5c Fix a typo in Changelog wrt new version 2023-07-03 14:42:27 -07:00
Peter Glotfelty
69e3449c0e Publish new version with fix #276 2023-07-03 13:49:32 -07:00
Samuel Moelius
93ea44dd12
Handle rustoc comments in #[derive(FromRepr)] (#276) 2023-07-03 13:45:32 -07:00
Peter Glotfelty
0a0def76bd
update ci version (#280)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2023-07-01 13:17:30 -07:00
Peter Glotfelty
2bcf86d0ca Update README and CHANGELOG for new version 2023-06-17 17:28:04 -07:00
Mendy Berger
85e2c1692b
Added enum_is (#257)
* Added enum_is

* feat(is): Use a simple match and cover all cases

* Removed dependency convert_case

* Added disabled support for enum_is
2023-06-17 17:58:53 -07:00
Josh McKinney
e6a9bf08c4
fix!: use the tuple value for to_string on default (#270)
The default attribute on a tuple like variant now causes the to_string
and display format to use the value of the tuple rather than the name
of the variant.

E.g. Color::Green("lime").to_string() will equal "lime" not "Green"

Fixes: how to round trip Display and EnumString with default="true" #86

BREAKING CHANGE
This changes how Display and ToString cause the following to renders:
```rust
#[strum(default)]
Green(String)
```
To maintain the previous behavior (use the variant name):
```rust
#[strum(default, to_string("Green"))]
Green(String)
```
2023-06-17 17:58:12 -07:00
CosmicHorror
2b71e10120
Update syn to v2 (#261) 2023-06-17 17:57:26 -07:00
Matt Schulte
67f0d1947d
Fix EnumCount with disabled variants (#268)
Do not include disabled variants in the count with EnumCount. Fixes #267
2023-06-17 17:50:15 -07:00
Jan Philipp Bittner
025b1b5687
add missing word (#263) 2023-05-06 15:24:04 -07:00
Rory Snively
30c5c16515
fix deprecation warning in additional_attributes example (#264) 2023-05-06 14:55:43 -07:00
Martin Kauppinen
635ab9511b
Add Train-Case case style (#256) 2023-03-12 14:48:07 -07:00
Kesavan Yogeswaran
405832679f
Fix doc comment for strum::EnumIter macro (#253)
The `EnumIter` macro's doc comment has a typo around the implemented
trait. The implemented trait is `strum::IntoEnumIterator`.
2023-02-26 11:08:58 -08:00
Alex
7efb86efbe
Change kebab_case to kebab-case in example (#248) 2023-01-02 16:00:42 -08:00
Peter Glotfelty
e772e203da
implement Debug for EnumIter (#240)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2022-10-15 12:00:20 -07:00
Mike Leany
dd0c2fa785
Fix doc comment for EnumIter (#242)
Comment now says that it iterates over variants of the enum rather than
variants of `Self`, which would be the iterator.
2022-10-15 11:59:55 -07:00
Alissa Tung
93d0886377
chore: fix typo (#239)
* chore: fix typo

* chore: fix typo
2022-09-25 12:10:49 -07:00
Tim Siegel
54771c0870
strum_macros::FromRepr: fix typo in documentation (#236) 2022-09-19 10:31:34 -07:00
Peter Glotfelty
7e8a9304bf Update changelog 2022-08-07 16:35:38 -07:00
Peter Glotfelty
d8278db866
add allows to prevent lint errors (#231)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2022-08-07 16:32:28 -07:00
Peter Glotfelty
0ba53fff6c Publishing a new version without #217 to enable phf 2022-06-24 17:53:45 -07:00
Peter Glotfelty
b5ba7cc12c
Revert "Add TryFrom to FromRepr (#217)" (#228)
This reverts commit ac757fa970.
2022-06-24 17:47:32 -07:00
Peter Glotfelty
5685f9b96d updated CHANGELOG with yanked package 2022-06-16 07:44:41 -07:00
Peter Glotfelty
b25ea1b9a0 Get ready to publish 0.24.1 2022-06-12 13:33:21 -07:00
Peter Glotfelty
a952fc0028
Peternator7/update phf logic (#224)
* Support phf crate for faster match on large enums

* comment

* add changelog entry

* add tests, embed phf, and improve lowercase support

* fix doc change

* Refactor & support case insensitive with case sensitive phf match

* more tests, some fixes of new implementation and prep for feature

* Modify the initial implementation.

Co-authored-by: Thomas BESSOU <thomas.bessou@hotmail.fr>
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2022-05-16 21:33:33 -07:00
Peter Glotfelty
c560f3e4c0
Disable the test_phf feature on 1.32 (#222)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2022-05-01 08:54:09 -07:00
Peter Glotfelty
b1befeb594 See if this gets the build fixed 2022-04-30 15:26:54 -07:00
Ten0
832dd862c7
Add support for PHF in EnumString (#220)
* Support phf crate for faster match on large enums

* comment

* add changelog entry

* add tests, embed phf, and improve lowercase support

* fix doc change

* Refactor & support case insensitive with case sensitive phf match

* more tests, some fixes of new implementation and prep for feature
2022-04-30 15:23:28 -07:00
ac757fa970
Add TryFrom to FromRepr (#217)
* Add TryFrom to FromRepr

* Fix building on rust < 1.34
2022-04-30 11:24:17 -07:00
Peter Glotfelty
054df849e1 Fix unit tests 2022-04-16 12:28:10 -07:00
Spenser Black
9465cd5dbb
Use full path for None in EnumIter (#214) 2022-03-14 09:22:19 -07:00
Peter Glotfelty
94460f006c Revert a small change from get_docs 2022-02-21 14:20:01 -08:00
Peter Glotfelty
96228c76cb Add updates for 0.24 2022-02-21 14:07:48 -08:00
Oren Ben-Kiki
e558e913f4
Add get_documentation() to EnumMessage. (#206)
* Add get_documentation() to EnumMessage.

* Address 1st review comments.

* Remove usage of strip_prefix to support older Rust versions.

Co-authored-by: Peter Glotfelty <glotfelty.2@osu.edu>
2022-02-21 13:37:25 -08:00
Marcel Hellwig
672ac26005
Clippy lints and some minor nitpicks (#212)
* add clippy.toml with an msrv

* fix clippy lints

* replace inefficient algorithm

* replace ::std with ::core in more places and comments

* fix some test warnings

* fix clippy lints in tests
2022-02-18 16:04:31 -08:00
matt rice
c676655d11
use core instead of std in a couple places. (#209) 2022-02-05 15:29:26 -08:00
daxpedda
260322fb7e
Add allow(clippy::use_self) to remove warnings from FromRepr (#211) 2022-02-05 15:28:57 -08:00
Alex Gaynor
fb88d04dcf
Update to heck 0.4 (#201) 2022-01-15 12:40:14 -08:00
Peter Glotfelty
b855edb463
Peternator7/enum iter doc comment (#204) 2022-01-14 06:54:03 -08:00
Peter Glotfelty
837c785a88
Pin clap version (#205)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2022-01-09 09:37:17 -08:00
Peter Glotfelty
4f6a556b9a Merge branch 'master' of https://github.com/Peternator7/strum 2022-01-08 12:11:33 -08:00
LJ
ced17d4c58
Add doc comment to FromRepr macro (#202)
This will help people who have missing_docs denied.
2022-01-08 12:08:45 -08:00
Peter Glotfelty
5d733fd1f3 Update package version to include patches 2021-11-20 11:34:26 -08:00
Peter Glotfelty
0c80602333
Add tests for nostd environment (#196)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-11-20 11:30:11 -08:00
Peter Glotfelty
2ba6b0a9c3
Run rustfmt over the whole tree (#195)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-11-19 18:31:08 -08:00
Tyler Hall
1e3acb64a7
Disambiguate associated items in trait impls (#193)
The addition of TryFrom<&str> for EnumString breaks for enums that have
a variant called "Error". Rewrite as <Self as Trait> where associated
types are used as the return type for trait functions.

Example:

```rust
pub enum Test {
    Error,
}
```

error: ambiguous associated item
   --> src/lib.rs:3:10
    |
3   | #[derive(EnumString)]
    |          ^^^^^^^^^^
    |
    = note: `#[deny(ambiguous_associated_items)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
2021-11-19 12:12:59 -08:00
Danny Milosavljevic
5c0ee93860
Use core::* instead of std::* in order to make it work in a no_std environment. (#192)
Co-authored-by: Danny Milosavljevic <daym@oxidecomputer.com>
2021-11-18 11:11:02 -08:00
Peter Glotfelty
5272fcea91 Tweak docs to format correctly and update crates to the newest version 2021-11-16 22:24:17 -08:00
Peter Glotfelty
c8cd49f4e3 Use rustversion instead of version_check in strum_tests 2021-11-16 21:56:51 -08:00
Andrew Burkett
aeaa19ad86
EnumIndex implementation (#185)
* Add EnumConstIndex

* Get working with discriminants

* Remove unused/(unneeded?) features

* Rename to EnumIndex and index(..). Make const_index conditional

* Get repr(..) working

* Fix issue to support rust 1.32

* Switch from VARIANT# to {ENUM}_{VARIANT} for variant constant names

* Expose constants as part of implementation

* Add discriminant error messages. Cargo fmt my code

* Add rustversion to make compilation conditional on 1.46

* Handle expr discriminants

* Fix generics handling

* Make constants always available. No need to only expose them when const_index is defined

* Change to FromDiscriminant. Only output a single function

* Don't make constants accessible

* Make rustversion a dev dependency in strum-tests due to upstream change

* Cleanup doc tests for const

* Rename to FromRepr/from_repr
2021-11-06 09:30:09 -07:00