Giter VIP home page Giter VIP logo

enum-utils's People

Contributors

ecstatic-morse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

enum-utils's Issues

Override visibility and/or name for `IterVariants`

It appears that the IterVariants derive will only produce a private fn iter() which makes it only useful in the module where the enum is defined. I'd like to see a way to override this:

pub mod foo {
    #[derive(enum_utils::IterVariants)]
    // well-behaved attributes are namespaced
    // also so you only have to declare the `enum_utils` attribute in `#[proc_macro_derive]`
    #[enum_utils(iter(visibility = "pub"))]
    pub enum Foo {
        Bar,
        Baz
    }
}

fn main() {
    let variants = foo::Foo::iter();
}

Additionally, it might be nice to override the generated method name:

#[derive(enum_utils::IterVariants)]
#[enum_utils(iter(name = "variants"))]
enum Foo {
    Bar,
    Baz
}

fn main() {
    let variants = Foo::variants();
}

Implement `Display` derive as a complement to `FromStr`

This exists in strum and derive-more but the former is complicated and the latter doesn't have FromStr or TryFrom<{repr}> derives for enums. I rather like the simplicity and narrowed scope of this crate and it'd be nice not to have to import multiple crates to get all the derives I need. I'd be glad to open a PR if you'd accept it.

Allow custom error type to be supplied

I want to use this in conjunction with structopt, whose derive macro expands to this:

.validator(|s| {
                        ::std::str::FromStr::from_str(s.as_str())
                            .map(|_: Eval| ())
                            .map_err(|e| e.to_string())
                    })

Obviously this won't work as the default error type () doesn't implement Display.

Already fixed problems is not available on crates.io

Last available version of the repository on crates.io is 0.1.1, however the building of the version is terminated with compilation error. Currently master branch is ok. Could you to update package on crates.io?

I tested on two different platforms and the result is the same:

  • stable-x86_64-unknown-linux-gnu (default)
    rustc 1.38.0 (625451e37 2019-09-23)

  • nightly-armv7-unknown-linux-gnueabihf (default)
    rustc 1.40.0-nightly (6767d9b90 2019-10-11)

P.S. It would be nice to push git tags for all releases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.