Slint enums lose underscores in Rust #5170
-
Im using a Slint enum to control the state the UI is in. It looks like this:
In Rust, the FooState enum loses the underscores, for example:
Am I missing the proper casing for enums in Slint? I'm planning to add quite a lot of states, losing the underscores hurts readability, and I don't like that my Rust names don't match the Slint names. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Enums are converted to camel case. So 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) |
Beta Was this translation helpful? Give feedback.
Enums are converted to camel case. So
hello_state
becomesHelloState
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
Which would be in rust:
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)