1
0
mirror of https://github.com/danog/strum.git synced 2024-12-12 09:29:39 +01:00
Commit Graph

136 Commits

Author SHA1 Message Date
horacimacias
42c16664a8
Fix EnumIter for enums named Option (#300)
Co-authored-by: Horaci Macias <hmacias@avaya.com>
2023-10-15 15:08:35 -07:00
Wyatt Herkamp
0199235bb0
Fix Generics Issue with enum_is (#305) 2023-10-15 15:07:46 -07:00
Michael Schubart
3664c5e8ca
Remove unused vectors (#304) 2023-10-15 15:06:49 -07:00
Wyatt Herkamp
af9b15b617
Add doc comment to EnumIs result (#301) 2023-10-15 15:05:55 -07:00
Peter Glotfelty
db553e3dcf
Merge pull request #285 from MendyBerger:try-as
Added EnumTryAs
2023-08-26 14:49:58 -07:00
Peter Glotfelty
3341c2f394 updated changelog to 0.25.2 2023-08-06 16:55:18 -07:00
hasezoey
2782412396
Enable doc-test for "strum_discriminants(vis(pub))" (#289) 2023-08-06 16:48:02 -07:00
Mendy Berger
4014b3e2d1 Requested changes in review 2023-07-31 16:44:38 -04:00
bouzuya
fcb9841a74
Add test and comment if camel_case is specified (#250)
Co-authored-by: Peter Glotfelty <glotfelty.2@osu.edu>
2023-07-29 15:00:13 -07:00
kraktus
fd519ec47f
Fix EnumIter macro code generation (#287)
* Add test to ensure macro call `::core`-related functions

Avoiding local core modules to break the macro-generated code.

Currently failing due to issue with `EnumIter` macros.

* Fix macro of `EnumIter`

close https://github.com/Peternator7/strum/issues/284

---------

Co-authored-by: kraktus <kraktus@users.noreply.github.com>
2023-07-29 14:58:18 -07:00
MendyBerger
e0f81e9caa Added EnumTryAs 2023-07-16 22:59:38 -04: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
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
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
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
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
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
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