Skip to content

Add crate_path option to EnumInfo #172

@ifiokjr

Description

@ifiokjr

Description

Add a crate_path option to the EnumInfo struct to allow patterns where other crates can reexport num_enum and allow consumers of their library to consume the From* macros without a direct dependency on the num_enum crate.

pub(crate) struct EnumInfo {
pub(crate) name: Ident,
pub(crate) repr: Ident,
pub(crate) variants: Vec<VariantInfo>,
pub(crate) error_type_info: ErrorType,
}

I'm happy to open a PR if this is something you're happy to use.

Example

use other_crate::num_num::IntoPrimitive;
use other_crate::num_num::TryFromPrimitive;

#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, TryFromPrimitive)]
#[num_enum(crate_path = ::other_crate::num_enum)]
pub enum MyEnum {
  A = 0,
  B = 1,
  C = 2,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions