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>
* 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
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.
* ToString is deprecated in favor of display.
* Remove doc(hidden)
* Remove references to `ToString` macro
Co-authored-by: Peter Glotfelty <peter@glotfelty.us>
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>
* 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
* 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`
* 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
* 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
* 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`.
* Add VariantNames trait with the variants() function which the EnumVariantNames macro implements
* Consider generics in the impl block + use absolute path for the trait