Skip to content

Commit

Permalink
Force ColorPickerFn to be Send + Sync (#3148) (#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
idanarye authored Aug 11, 2023
1 parent 1e885ab commit ea6bdfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/egui/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2245,3 +2245,9 @@ impl Ui {
}
}
}

#[test]
fn ui_impl_send_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<Ui>();
}

0 comments on commit ea6bdfc

Please sign in to comment.