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

194 Commits

Author SHA1 Message Date
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
Danny Milosavljevic
1a703a4103
Use core::result instead of std::result in order to make it work in a no_std environment. (#189)
Co-authored-by: Danny Milosavljevic <daym@oxidecomputer.com>
2021-10-26 12:17:54 -07:00
Dominik Spicher
7b68e4dc44
Add TryFrom<&str> to EnumString (#186)
The implementation simply delegates to `std::str::FromStr`.

To maintain compatibility with Rust 1.32, a new dependency
is introduced which allows us to emit the `TryFrom<&str>`
implementation only for Rust 1.34 and above when
`std::convert::TryFrom` was stabilized.
2021-10-26 12:16:57 -07:00
Peter Glotfelty
f50fc72165
Update README.md
Fix a typo in the readme
2021-10-14 09:12:09 -07:00
Peter Glotfelty
08583fcb11
Make changes necessary for version 0.22 (#181)
* Make changes necessary for version 0.22

* Update changelog

Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-10-10 20:47:24 -07:00
Peter Glotfelty
1ec35285a0
Update documentation to include listing all the supported case styles. (#182)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-10-10 12:45:19 -07:00
Peter Glotfelty
07f9fe30e2
ToString is deprecated in favor of display. (#180)
* ToString is deprecated in favor of display.

* Remove doc(hidden)

* Remove references to `ToString` macro

Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-10-09 15:03:33 -07:00
Jonathan Chan Kwan Yin
6119f107e2
Fixed incorrectly commented deprecated attribute (#178)
* Fixed incorrectly commented `deprecated` attribute

* Also deprecate the `AsStaticRef` macro.

* Changed deprecation version to 0.22.0
2021-10-07 21:43:49 -07:00
Peter Glotfelty
75519edcff pin bitflags version in tests project to fix builds 2021-10-02 08:30:03 -07:00
Cor Peters
db5071874b
Features/no std (#171)
* Added std feature to allow for no_std usage

* added no_std attr

Co-authored-by: Luctius <luctius@gmail.com>
2021-08-03 21:19:21 -07:00
Peter Glotfelty
71894b5431
Update appveyor.yml (#173) 2021-08-03 21:16:27 -07:00
Billy Chan
e9d3b59a80
Re-export macros (#170)
* Re-exportable macros

* Rename derive attribute to `Crate`

* Add unit tests

* Test nested module

* Rename derive attribute to `crate`

* cargo fmt
2021-07-16 20:40:19 -07:00
Peter Glotfelty
5326d3229f
publishing version 0.21.1 to handle #164 (#165)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-06-02 08:50:35 -07:00
Matt W
dcd8df14bf
fix for field not method complaint in strum_macro's metadata.rs (#164) 2021-06-01 18:34:42 -07:00
Peter Glotfelty
c5a4b5e932
Update docs for 0.21 (#163)
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
2021-06-01 18:32:56 -07:00
Franz Dietrich
81df48a15f
Add allow(use_self) to remove warnings. (#161) 2021-05-26 10:06:22 -07:00
Ian Jackson
3869b6fa90
enum messages: Make the returned values all 'static (#160)
This is (at least in theory) a breaking change, because someone might
have implemented this trait by hand, and their implementation won't
be declared as returning 'static lifetimes.

Closes #159

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-18 15:52:33 -07:00
Peter Glotfelty
f71830c5fe
Pin exact version of enum_variant_type (#162) 2021-05-15 00:28:52 -07: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
d0977780d8
Remove the "rename" feature (#149) 2021-03-06 11:46:13 -08:00
Laurence Tratt
39e76b630f
Document the existence of the auto-From implementations (#151)
* Tweak wording.

* Reformat.

* Document the existence of the auto-From implementation.
2021-02-21 12:57:31 -08:00
Peter Glotfelty
c050dbd610
Update msrv because of heck. (#150) 2021-02-21 12:54:28 -08:00
Amrit Rathie
fb2f1b25ae
docs: Minor version in README docs.rs links (#148)
Use semver minor version rather than patch version in README.

Since doc.rs can resolve crate versions just like `cargo`, this will make the links point to the latest
version of the documentation.
2021-02-13 17:39:41 -08:00
Rudi Benkovič
684f119dab
Replaced ::std with ::core where applicable. (#145)
This makes these macros usable with `no_std` projects.
2021-02-06 08:28:50 -08: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
90047fee86
Replace macro panics with syn::Error (#135) 2020-10-19 09:56:49 -07: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
Jonas Platte
4ad39923d0
Refactor (#133)
* Remove unnecessary main in doctest

* Use syn::parse_macro_input!

* Add spans to attribute parse errors

* Add spans to more attribute errors

* Fix indentation

* Consistently import syn AST types
2020-10-07 22:18:30 -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
Michael Kefeder
89b9c14731
Wiki to doc tests (#121)
* example usage as doctests added to the strum_macros crate

* removed links to to wiki example code and documentation of the macros

* added attribute documentation as a module in strum and linked to it
2020-10-06 10:17:06 -07:00
Jonas Platte
7e64a470b1
Raise an error un malformed strum attributes (#119) 2020-09-29 10:01:29 -07: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
c9e1a0e16d
Merge pull request #111 from Peternator7/peternator7/fix-msrv-issues
Fix issues that were preventing the code from compiling on 1.31.1
2020-09-17 06:23:12 -07:00
Peter Glotfelty 🚀
5b89fb7bfc fix indentation 2020-09-17 05:09:18 +00:00
Peter Glotfelty 🚀
4824b1b3ab added newline 2020-09-17 05:02:08 +00:00