Skip to content

add support for global SelectValue name#49

Open
vic1707 wants to merge 1 commit intobugadani:mainfrom
vic1707:display_as-at-enum-level
Open

add support for global SelectValue name#49
vic1707 wants to merge 1 commit intobugadani:mainfrom
vic1707:display_as-at-enum-level

Conversation

@vic1707
Copy link

@vic1707 vic1707 commented Feb 18, 2025

currently doing

#[derive(embedded_menu::SelectValue, PartialEq, Eq, Clone, Copy)]
#[display_as(">")]
pub enum Page {
    Main,
    #[display_as("toto")]
    InputDebug,
    SelectInput,
    SelectOutput,
    Settings,
}

compiles but #[display_as(">")] doesn't do anything, we need to do

#[derive(embedded_menu::SelectValue, PartialEq, Eq, Clone, Copy)]
pub enum Page {
    #[display_as(">")]
    Main,
    #[display_as("toto")]
    InputDebug,
    #[display_as(">")]
    SelectInput,
    #[display_as(">")]
    SelectOutput,
    #[display_as(">")]
    Settings,
}

which can be done better.

with the current pr, a top level attribute (like shown in the first example) gives

impl embedded_menu::items::menu_item::SelectValue for Page {
    fn next(&mut self) {
        *self = match self {
            Self::Main => Self::InputDebug,
            Self::InputDebug => Self::SelectInput,
            Self::SelectInput => Self::SelectOutput,
            Self::SelectOutput => Self::Settings,
            Self::Settings => Self::Main,
        };
    }
    fn marker(&self) -> &str {
        match self {
            Self::Main => ">",
            Self::InputDebug => "toto",
            Self::SelectInput => ">",
            Self::SelectOutput => ">",
            Self::Settings => ">",
        }
    }
}

The top level attribute can be overwritten by the same attribute on each specific variant

@bugadani
Copy link
Owner

I appreciate your enthusiasm but I have no energy or motivation to maintain this crate. Feel free to fork it and turn it into whatever you like it to be.

@vic1707
Copy link
Author

vic1707 commented Feb 19, 2025

Okay 👍
sorry for the inconveniences 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants