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

50 Commits

Author SHA1 Message Date
Peter Glotfelty
3386914c10 Pin exact version of enum_variant_type 2021-05-15 01:00:52 +00:00
Chayim Refael Friedman
ca60910df0
Support case-insensitive EnumString (#157)
Fixes #154
2021-05-02 20:59:48 -07:00
Vlad Frolov
089aec8303
Added a pass-through attribute support to EnumDiscriminants (#153)
* Added a pass-through attribute support to EnumDiscriminants

* added a test per review comment
2021-03-19 10:45:55 -07:00
Peter Glotfelty 🚀
96ee0a9a30 Updated changelog for strum 0.20 2020-11-21 20:13:44 +00:00
Mark LeMoine
ddb9c2682e
Adding visibility option vis(...) to #[strum_discriminants] (#137) (#138)
* Adding vis to EnumDiscriminants (#137)

* Improved doctest example names (#137)

* Fixing incorrect occurrence_error attr string

* Using r#pub on doctest

* Adding tests for discriminant visibility, and rustc-cfg for bare "pub"

* Doing local import with "self::"

* Back to having tests pass on latest stable

* Moved sample doctest with vis example to separate nocompile block
2020-11-15 20:13:50 -08:00
Jonas Platte
25eaa5a12c
More attribute refactoring (#134)
* Remove unused method NestedMetaHelpers::expect_lit

* Use references match instead of ref patterns

* Use custom meta types instead of syn::Meta

This should improve both readability of the code and the quality of
error messages.

* Replace TryFrom<&str> with FromStr

* Restore Rust 1.31.1 compatibility

* Re-run `cargo fmt`
2020-10-15 09:27:38 -07:00
Peter Glotfelty 🚀
441316121b Updated changelog and readme with new version as well as tweaked docs slightly. 2020-10-07 05:52:12 +00:00
Peter Glotfelty
1d2778842b
Re-Enable Travis via travis.com (#112)
* Enable travis

* add build.r to re-enable try_from
2020-09-17 11:21:41 -07:00
Jonas Platte
b517f232aa
Update strum to Rust edition 2018 (#110)
* Set all crates to edition 2018

* Remove redundant imports

* Remove extern crate declarations for cargo dependencies
2020-09-17 11:21:21 -07:00
Peter Glotfelty 🚀
38fdea4ad8 Fix issues that were preventing the code from compiling on 1.31.1 2020-09-17 05:01:05 +00:00
Peter Glotfelty 🚀
06bbb62624 ran cargo fmt over the whole tree 2020-08-06 00:09:12 +00:00
Peter Glotfelty 🚀
9508a31f4b Didn't actually change enum variant names in the 0.19 like I meant to. 2020-08-02 00:07:38 +00:00
Peter Glotfelty
7e5b5e43e8
Peternator7/0.19 (#101)
* Changelog for 0.19

* Updated version in Cargo.toml
2020-08-01 16:54:43 -07:00
Peter Glotfelty
c5fc096ece
Pulled some of the core logic out of plugins (#100)
* Major refactor of code.

* More minor refactorings

* renamed variables

* add repository link
2020-07-29 09:36:48 -07:00
Peter Glotfelty 🚀
ec3297242c Replaced const fn count with associated constant. 2020-07-26 04:41:15 +00:00
Peter Glotfelty
95645cac52
Fix Display macro to handle fill/align (#95) 2020-06-12 13:54:51 -07:00
root
da37cc3141 Made a fix for #80 2020-03-01 23:55:53 +00:00
t-mw
043b60f6d8
Apply serialize_all casing to get_serializations (#84)
* Apply serialize_all casing to get_serializations

* Update changelog

* Fix grammar
2020-02-10 15:55:18 -08:00
Azriel Hoh
2b83eceba6
Bugfix/73/whitelist variant attributes to copy (#82)
* Whitelist attributes to copy to `EnumDiscriminants`' variants.

* Updated `CHANGELOG.md`.
2020-02-08 10:54:44 -08:00
Nevsor
8db6a31332 Implemented DoubleEndedIterator for EnumIter. (#60)
* Implemented DoubleEndedIterator for EnumIter.

* Fixed overlapping behaviour of next and next_back.

* Changed names of tests I accidentally swapped.

* Fixed size_hint() for EnumIter.

* Implemented more efficient version of nth() for EnumIter.

* Added another test of  `next` and `next_back`, where the last call is to `next`.
2019-12-19 14:44:30 -08:00
Waffle Lapkin
eea32dbf7f Const enum variants names (#75)
* Add implementing const `VARIANTS` by `EnumVariantsNames`, deprecate old `::variants`

* Move `const VARIANTS` to `VariantNames` trait

* Remove `VariantNames::variants` function
2019-12-12 13:39:10 -08:00
Spanfile
bc8fa93ee8 Move EnumVariantsNames into a trait which the macro implements (#74)
* Add VariantNames trait with the variants() function which the EnumVariantNames macro implements

* Consider generics in the impl block + use absolute path for the trait
2019-11-23 20:58:10 -08:00
Herman Venter
e981f240d6 Add checks to guard against overflow in iterator methods. (#76) 2019-11-16 17:33:14 -08:00
uHOOCCOOHu
00397fe0a3 Add feature derive for re-exporting proc macros. 2019-08-16 11:52:58 -07:00
Evgeniy Dushistov
640c0bb713 Implement serialize_all=UPPERCASE (#48)
* Implement serialize_all=UPPERCASE

* applying rustfmt 1.2.2-stable

* handling of all options listed in serde docs for compatibility

See https://serde.rs/container-attrs.html#container-attributes
2019-07-29 08:26:29 -07:00
Pascal Hertleif
96daaf4021 Add EnumVariantNames (#56)
* Add `EnumVariantNames`

This derive adds a static `variants()` methods yielding the names of
the enum variants. This happens to be exactly what clap [wants][1], and
is the last puzzle piece to use strum with clap/structopt.

[1]: https://docs.rs/clap/2.33.0/clap/macro.arg_enum.html

* Expand readme section for `EnumVariantNames`

* Return slice instead of array

This reduces the risk of breaking the public API by accident when adding
a new variant.

* Fix typo in Readme

* Add generic doc comment to `variants()` method

* Add test case using `variants` in clap/structopt
2019-07-15 10:06:33 -07:00
Peter Glotfelty
970b5cec40
Macro renames (#46)
* Updating the README

* Did lots of updates for the documentation

* Improving formatting in a few places

* Consolidated docs to make it easier to keep up to date

* Updating workspace

* Revved version in docs
2019-03-26 20:44:39 -07:00
Peter Glotfelty
68d7fba35b
Ran rustfmt on the whole tree and added a note about compatibility (#44)
* Ran rustfmt on the whole tree and added a note about compatibility

* Removing a doc-comment
2019-03-03 23:27:59 -08:00
Tang King Fai
7605c67ec6 Fix serialize_all in AsRefStr, AsStaticStr and IntoStaticStr (#42) 2019-02-19 06:06:45 -08:00
Peter Glotfelty 🚀
e79a6fea80 Updated documents 2018-12-24 08:58:14 -08:00
Evgeniy Dushistov
fe6c20a249 implement From<Enum> for &'static str in case of AsStaticRef derive (#40)
* implement From<Enum> for &'static str in case of AsStaticRef derive

* make possible to use <&'static str>::from(Enum) without strum crate

* mark AsStaticRef trait as deprecated
2018-12-24 08:33:57 -08:00
Peter Glotfelty 🚀
c22c8ca7a9 Updated docs and revved version numbers 2018-12-05 11:52:34 -08:00
Peter Glotfelty 🚀
b66f15edb5 Merge branch 'master' of github.com:Peternator7/strum 2018-12-05 11:05:36 -08:00
Evgeniy Dushistov
e040bf4050 feature: add enum count macros (#37)
* feature: add enum count macros

fix #15

* add docs for EnumCount
2018-11-05 10:36:09 -08:00
Peter Glotfelty 🚀
e75626a59f Revved Version Numbers 2018-09-26 13:02:53 -07:00
Azriel Hoh
1c00f6cfa5 Feature/33/derive enum variants (#34)
* Run rustfmt over repository.

* Bump `syn` to 0.15

* Implemented ability to `serialize_all` using cases from `heck`.

Issue #21

* Use `path` and `version` in dependency specifications.

Issue #21

* Updated documentation.

Issue #21

* Added `CHANGELOG.md`.

* Also convert case when deriving `Display`.

Issue #21

* Added `EnumDiscriminants` derive.

Issue #33

* Added the ability to rename derived `EnumDiscriminants`.

Issue #33

* Updated `README.md` and lib.rs docs.

Issue #33

* Updated `CHANGELOG.md`.

Issue #33

* WIP: refactoring to allow attributes on discriminants enum.

* Use single `strum_discriminants` top level attribute.

Issue #33

* Allow multiple declarations of `strum_discriminants` attribute.

Issue #33

* Pass through all other attributes to discriminant enum.

Issue #33

* Add `impl From<MyEnum> for MyEnumDiscriminants`.

Issue #33

* Add `impl<'_enum> From<&'_enum MyEnum> for MyEnumDiscriminants`.

Issue #33

* Added complex case test for `From` derivation.

Issue #33

* Added docs to some helper functions.

* Added docs about `From` impls.

Issue #33
2018-09-26 12:13:45 -07:00
Peter Glotfelty
b6e4e66157
Did a little bit of refactoring and added some docs around AsStaticStr (#28)
* Did a little bit of refactoring and added some docs around AsStaticStr

* Revving the version in the cargoo.toml

* Managing Cargo.toml is a bit tedious when deploying packages that depend on each other

* Updated Cargo.toml
2018-06-26 08:22:19 -07:00
らりお (YOSHIOKA Takuma)
3988beefb9 Add AsStaticRef trait and let derive(AsRefStr) implement it (#24)
`#[derive(AsRefStr)]` will implement `AsStaticRef<str>`, and it
enables us to get `&'static str` by `AsStaticRef::<str>::as_static()`.

This will solve #23.
2018-05-26 10:57:04 -07:00
Malte Thiesen
ae40df1383 Implement Clone trait for enum iterators. (#18) 2018-04-16 09:43:32 -07:00
Peter Glotfelty 🚀
f039c629e2 Implemented Display for enums and added exactsizeiter to enumiter 2018-03-10 13:06:17 -08:00
らりお (YOSHIOKA Takuma)
af58a6d403 Add derive(AsRefStr) implementation (#10)
Implements AsRef<str> as a non-allocating alternative to deriving ToString. Docs will come later
2017-08-23 19:18:23 -07:00
Peternator7
a82aaa1e0d Fixed a link in the readme 2017-04-15 19:01:58 -07:00
Peternator7
bb2a37e9b6 Refactored deriviations into different files and added a ToString implementation 2017-04-15 18:08:49 -07:00
Peter Glotfelty
9dcade9077 Added one more test file 2017-02-23 00:09:57 -08:00
Peter Glotfelty
1801a300d3 Fixed some documentation bugs 2017-02-15 21:16:16 -08:00
Peter Glotfelty
033a376130 Added more test cases and fixed a small bug in how EnumIter handles generics 2017-02-15 19:16:40 -08:00
Peter Glotfelty
c52cd5942a Revised documentation and it reads better now. Started writing a test crate. 2017-02-11 22:44:40 -08:00
Peter Glotfelty
bbdceacd58 Fixed all the doc tests to actually run. 2017-02-11 11:42:32 -08:00
Peter Glotfelty
e9f28d8273 Added lots more documentation to the project. 2017-02-09 00:23:55 -08:00
Peter Glotfelty
81ab1483bc Added support for lifetimes and generic bounds on enums. Also added support for a default case in from_str and a detailed_message 2017-02-08 23:06:28 -08:00