1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

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

This commit is contained in:
Idan Arye
2023-08-11 09:23:29 +03:00
committed by GitHub
parent 1e885abe08
commit ea6bdfc1c9
2 changed files with 8 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ impl State {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// type alias for boxed function to determine row color during grid generation // 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 { pub(crate) struct GridLayout {
ctx: Context, ctx: Context,
@@ -312,7 +312,7 @@ impl Grid {
/// Setting this will allow for dynamic coloring of rows of the grid object /// 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 pub fn with_row_color<F>(mut self, color_picker: F) -> Self
where 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.color_picker = Some(Box::new(color_picker));
self self

View File

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