Skip to content

Slint enums lose underscores in Rust #5170

Discussion options

You must be logged in to vote

Enums are converted to camel case. So hello_state becomes HelloState which match the convention in rust.
In Slint the convention for enums is to use lower case snake/kebab case. So The idomatic way tyo do it would be

export enum FooState {
    hello-state,
    happy-state,
    sad-state,
}

Which would be in rust:

let foo_state = FooState::HappyState;

Admittedly, we should probably have kept the underscore when the name was in upper case. But now that would be a breaking change unfortunately. (Unless we add compiler option or attribute for this kind of configuration)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@otiv-wannes-vanleemput
Comment options

Answer selected by otiv-wannes-vanleemput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants