]> uap-core.de Git - note.git/commitdiff
refactor set_states/set_visibility_states function to use generic Into<i32> instead...
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 11 Aug 2026 19:47:46 +0000 (21:47 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 11 Aug 2026 19:47:46 +0000 (21:47 +0200)
ui-rs/src/ui/button.rs
ui-rs/src/ui/container.rs
ui-rs/src/ui/image.rs
ui-rs/src/ui/label.rs
ui-rs/src/ui/list.rs
ui-rs/src/ui/text.rs
ui-rs/src/ui/webview.rs

index 7a90549477e2d24fc2be1e162d86602b76452863..ded533bb70a5e468190b4682473a4d726892b111 100644 (file)
@@ -400,14 +400,16 @@ impl<'a, T> ButtonBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_button_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_button_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -592,14 +594,16 @@ impl<'a, T> ToggleBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_toggle_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_toggle_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -777,14 +781,16 @@ impl<'a, T> LinkButtonBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_linkbutton_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_linkbutton_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
index 389776983dab5ed88b266417b487283f4a4b1293..83ec79b64db2a8167df3a6409c4ae6dd9aa27a61 100644 (file)
@@ -463,7 +463,8 @@ impl<'a, T> ContainerBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_container_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -706,7 +707,8 @@ impl<'a, T> FrameBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_frame_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -911,7 +913,8 @@ impl<'a, T> SplitPaneBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_splitpane_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -1289,7 +1292,8 @@ impl<'a, T> TabViewBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_tabview_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
index 042a2d4bbaa02e3eec01f4932c4f136e366ca303..a97e546b62243182063c91e610f7566b7761c488 100644 (file)
@@ -321,7 +321,8 @@ impl<'a, T> ImageViewerBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_imageviewer_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
index 14de16aab1a923b740311801ba619a9bb7ed52db..11264a775e5de9e983542dafc9bb6e9e6313864f 100644 (file)
@@ -283,14 +283,16 @@ impl<'a, T> LabelBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_label_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_label_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
index 3bb7c6969b17818236eab44369c963a39ad53ce8..bbb7c2982d418591945e32754a2220531baacfc8 100644 (file)
@@ -381,14 +381,16 @@ impl<'a, T, E> ListViewBuilder<'a, T, E> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_list_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_list_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -620,14 +622,16 @@ impl<'a, T, E> TableViewBuilder<'a, T, E> {
     }
 
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_list_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_list_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -811,14 +815,16 @@ impl<'a, T, E> SourceListBuilder<'a, T, E> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_sourcelist_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_sourcelist_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
index 5eb92ab85dfc801eaf76c0fbad2f26bdfa64e9c1..ca67ffcb7bce05f53e70e7c487966c1d1211538b 100644 (file)
@@ -308,14 +308,16 @@ impl<'a, T> TextAreaBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_textarea_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_textarea_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
@@ -620,14 +622,16 @@ impl<'a, T> TextFieldBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_textfield_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_textfield_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }
index 8d572f7762b90016d672045f3d5ae620c5656198..c15b5c83a390db2676a413bbc08d837719d1a85c 100644 (file)
@@ -217,14 +217,16 @@ impl<'a, T> WebViewBuilder<'a, T> {
         self
     }
 
-    pub fn visibility_states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn visibility_state<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_webview_args_set_visibility_states(self.args, states.as_ptr(), states.len() as c_int);
         }
         self
     }
 
-    pub fn states(&mut self, states: &[i32]) -> &mut Self {
+    pub fn states<S: Copy + Into<i32>>(&mut self, states: &[S]) -> &mut Self {
+        let states: Vec<i32> = states.iter().copied().map(Into::into).collect();
         unsafe {
             ui_webview_args_set_states(self.args, states.as_ptr(), states.len() as c_int);
         }