Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

num-derive dependency worth it? #57

Closed
HeroicKatora opened this issue Sep 27, 2019 · 3 comments · Fixed by #63
Closed

num-derive dependency worth it? #57

HeroicKatora opened this issue Sep 27, 2019 · 3 comments · Fixed by #63
Labels
easy enhancement New feature or request

Comments

@HeroicKatora
Copy link
Member

HeroicKatora commented Sep 27, 2019

The crate currently uses num-derive to add some num-traits::FromPrimitive implementations to a couple of enumerations. Since this is done via a procmacro it requires sequencing in the compilation pipeline, compiling proc-macro2/syn prior. All cases are simple enumerations such as :

pub enum Type {
    BYTE = 1,
    ASCII = 2,
    SHORT = 3,
    LONG = 4,
    RATIONAL = 5,
}

The functionality could also be added with a standard macro in such simple cases, see this example in smoltcp which adds very similar converters for std::convert::{From, To}.

@birktj
Copy link
Member

birktj commented Oct 14, 2019

It is probably not necessary, for example we already use a macro to create the Tags enum. A new macro that adds From and To impls should be fine.

@birktj birktj added easy enhancement New feature or request labels Oct 14, 2019
@Robzz
Copy link
Member

Robzz commented Oct 14, 2019

Yeah it's totally droppable. image used to depend on it, but only because of the tiff code, and I removed it from image when extracting the code into this crate. It's probably worth doing.

@HeroicKatora
Copy link
Member Author

One remaining question is one of style. Either go with the Unknown(_) variant from Tag or make the conversion return an Option like it does right now in the FromPrimitive trait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants