Browse Source

Force `ColorPickerFn` to be `Send + Sync` (#3148) (#3233)

pull/3236/head
Idan Arye 1 year ago
committed by GitHub
parent
commit
ea6bdfc1c9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      crates/egui/src/grid.rs
  2. 6
      crates/egui/src/ui.rs

4
crates/egui/src/grid.rs

@ -47,7 +47,7 @@ impl State {
// ----------------------------------------------------------------------------
// type alias for boxed function to determine row color during grid generation
type ColorPickerFn = Box<dyn Fn(usize, &Style) -> Option<Color32>>;
type ColorPickerFn = Box<dyn Send + Sync + Fn(usize, &Style) -> Option<Color32>>;
pub(crate) struct GridLayout {
ctx: Context,
@ -312,7 +312,7 @@ impl Grid {
/// Setting this will allow for dynamic coloring of rows of the grid object
pub fn with_row_color<F>(mut self, color_picker: F) -> Self
where
F: Fn(usize, &Style) -> Option<Color32> + 'static,
F: Send + Sync + Fn(usize, &Style) -> Option<Color32> + 'static,
{
self.color_picker = Some(Box::new(color_picker));
self

6
crates/egui/src/ui.rs

@ -2245,3 +2245,9 @@ impl Ui {
}
}
}
#[test]
fn ui_impl_send_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<Ui>();
}

Loading…
Cancel
Save