Skip to content

Allow debug() on enums #499

@RReverser

Description

@RReverser

I have an enum that already has a pub const fn as_str(&self) -> &str function. I want to reuse it for both Display and Debug implementations.

I have no problem doing just that with derive_more::Display, but for some reason the Debug counterpart error out:

#[derive(PartialOrd, Ord, PartialEq, Eq, Clone, Copy, derive_more::Debug, derive_more::Display)]
#[display("{}", self.as_str())]
#[debug("{}", self)] // <-- #[debug("...", ...)]` attribute is not allowed on enum, place it on its variants instead
pub enum DeviceType {
  Telescope,
  Camera,
  // ...
}

This seems like an artificial limitation - I assume there's no technical reason for debug() attribute behaving differently than display()?

Metadata

Metadata

Assignees

Labels

enhancementk::apiRelated to API (application interface)

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions