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

122 Commits

Author SHA1 Message Date
Peter Glotfelty
98b41a5354 Fixed an issue with EnumIter overflowing 2019-12-20 02:28:30 +00:00
Peter Glotfelty
6ba428fd1a Updating readme to reflect new version 2019-12-19 23:18:17 +00: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
Cedric Hutchings
a94c8b0ce1 Replace 'variantes' with 'variants' in README.MD (#79) 2019-12-12 10:54:32 -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
Peter Glotfelty
9310855c82
Refactoring code and updating syn + quote (#71)
* Upgrading Syn and Quote to 1.0 and performing refactoring of helpers

* added newlines at the end of some files

* Did additional refactoring and added helpful trait methods to improve readability

* Shortened README and moved content to the wiki

* Updated README and changelog

* ran cargo fmt
2019-09-18 11:24:14 -07:00
tcharding
efed58502a Update attribute docs for strum_discriminants
Currently the README does not mention that extra attributes may be
passed to `#[strum_discriminants()]` and that these will be added as
attributes on the generated enum.  This is a cool feature, we should
document it.
2019-08-16 11:55:16 -07: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 🚀
1f4a3b2534 Revving package strum 2019-03-03 23:33:01 -08: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
Dale Wijnand
e58053b065 Allow enum count const to have missing docs (#43) 2019-02-18 12:44:22 -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 🚀
cb3a611b0e Updating one little mistake in the readme 2018-12-05 11:54:09 -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)
c91854c2f1 Bump dependencies (syn and quote) (#26)
syn-0.14 and quote-0.6 have been released, and they have breaking
changes.
2018-06-23 09:02:34 -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
らりお (YOSHIOKA Takuma)
e2ed13ad07 Disable missing_docs lint for new types created by EnumIter (#25) 2018-05-23 07:14:17 -07:00
らりお (YOSHIOKA Takuma)
179e8eac35 Bump dependencies (mainly syn crate) (#22)
* Bump dependencies

* Cache intepreted meta to reduce memory allocation
2018-05-12 15:29:21 -07:00
Malte Thiesen
ae40df1383 Implement Clone trait for enum iterators. (#18) 2018-04-16 09:43:32 -07:00
Peter Glotfelty 🚀
e0572b7f6b Updating the docs 2018-03-10 13:10:00 -08:00
Peter Glotfelty 🚀
f039c629e2 Implemented Display for enums and added exactsizeiter to enumiter 2018-03-10 13:06:17 -08:00
Alex Burka
788cb9a0cf don't suggest wildcard dependencies (#14)
* don't suggest wildcard dependencies in readme
* don't suggest wildcard deps in docs
2018-02-08 16:12:17 -08:00
Adam Wittenberg
40c510304c Fix associated type in example generated code (#11) 2017-10-30 10:53:58 -07:00
Peternator7
55f61035f7 Updated README to include AsRefStr 2017-08-23 22:20:39 -07: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
c9bba73f9b Updated Cargo.toml 2017-07-01 08:12:00 -07:00
kyren
86a02a4833 Add some missing absolute module paths 2017-06-30 14:36:13 -07:00
wangcong
d0ae6ff71d fix README Some path (#7)
* fix README `Some` path
* add missing `
2017-06-29 13:51:50 -07:00
Peter Glotfelty
645797ec90 Merge pull request #6 from NickeZ/patch-1
Fixed mark down in README
2017-06-29 13:50:38 -07:00
Niklas Claesson
56611a5cf4 Update README.md
Missed one tick
2017-06-28 22:50:43 +02:00
Peter Glotfelty
2fa1b869de Merge pull request #3 from Peternator7/features/tostring
Features/tostring
2017-04-15 19:11:41 -07:00
Peternator7
a82aaa1e0d Fixed a link in the readme 2017-04-15 19:01:58 -07:00
Peternator7
fbea713633 Updated Version. Changed Readme 2017-04-15 18:54:49 -07:00
Peternator7
bb2a37e9b6 Refactored deriviations into different files and added a ToString implementation 2017-04-15 18:08:49 -07:00
Peter Glotfelty
c171612524 Added an Appveyor.yml and fixed small issues in the Cargo.toml 2017-02-25 08:48:20 -08: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