Skip to content

Commit

Permalink
API review: Remove accidental public strum dependency
Browse files Browse the repository at this point in the history
Deriving strum::EnumIter on a publicly exposed enum (like PointerEventButton) implies visibility into types that strum declares. This was added just for testing
in systest and can be solved differently.

Amends a1857e6
  • Loading branch information
tronical committed Jul 5, 2024
1 parent 89b80eb commit a16e86b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/backends/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ pb-rs = { version = "0.10.0", optional = true, default-features = false }
[dev-dependencies]
slint = { workspace = true, default-features = false, features = ["std", "compat-1-2"] }
i-slint-core-macros = { workspace = true }
strum = { workspace = true }
i-slint-common = { workspace = true }
17 changes: 14 additions & 3 deletions internal/backends/testing/systest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,19 @@ fn convert_pointer_event_button(

#[test]
fn test_accessibility_role_mapping_complete() {
use strum::IntoEnumIterator;
for role in i_slint_core::items::AccessibleRole::iter() {
assert!(convert_accessible_role(role).is_some());
macro_rules! test_accessiblity_enum_mapping_inner {
(AccessibleRole, $($Value:ident,)*) => {
$(assert!(convert_accessible_role(i_slint_core::items::AccessibleRole::$Value).is_some());)*
};
($_:ident, $($Value:ident,)*) => {};
}

macro_rules! test_accessiblity_enum_mapping {
($( $(#[doc = $enum_doc:literal])* $(#[non_exhaustive])? enum $Name:ident { $( $(#[doc = $value_doc:literal])* $Value:ident,)* })*) => {
$(
test_accessiblity_enum_mapping_inner!($Name, $($Value,)*);
)*
};
}
i_slint_common::for_each_enums!(test_accessiblity_enum_mapping);
}
2 changes: 1 addition & 1 deletion internal/core/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ declare_item_vtable! {
macro_rules! declare_enums {
($( $(#[$enum_doc:meta])* enum $Name:ident { $( $(#[$value_doc:meta])* $Value:ident,)* })*) => {
$(
#[derive(Copy, Clone, Debug, PartialEq, Eq, strum::EnumString, strum::Display, strum::EnumIter, Hash)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, strum::EnumString, strum::Display, Hash)]
#[repr(u32)]
#[strum(serialize_all = "kebab-case")]
$(#[$enum_doc])*
Expand Down

0 comments on commit a16e86b

Please sign in to comment.