Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmerlin committed Nov 1, 2023
1 parent 6417949 commit 6b28803
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ release it on crates.io.
An example using most of the crates is available [here](https://lucasmerlin.github.io/hello_egui/).
Source code in [fancy-example](fancy-example).

## **hello_egui**, this crate
## [**hello_egui**](https://crates.io/crates/hello_egui), this crate
A collection of reexports for the other crates, if you want to use all or most of them.
You can toggle individual features to only include the crates you need. By default, all crates are included.
Only includes crates that have been released on [crates.io](https://crates.io/).
Expand Down
16 changes: 11 additions & 5 deletions crates/egui_suspense/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ use std::fmt::{Debug, Display};

type CallbackFn<T> = dyn FnOnce(T) + Send;

type ReloadFn<T, E> = dyn FnMut(Box<CallbackFn<Result<T, E>>>) + Send + Sync;

type ErrorUiFn<E> = dyn Fn(&mut Ui, &E, &mut State<'_>) + Send + Sync;

type LoadingUiFn = dyn Fn(&mut Ui) + Send + Sync;

/// Helper struct to call the reload function.
pub struct State<'a> {
/// True if this is a reloadable suspense.
Expand All @@ -28,10 +34,10 @@ pub struct EguiSuspense<T: Debug, E: Display + Debug = String> {
inbox: UiInbox<Result<T, E>>,
data: Option<Result<T, E>>,

reload_fn: Option<Box<dyn FnMut(Box<CallbackFn<Result<T, E>>>) + Send + Sync>>,
reload_fn: Option<Box<ReloadFn<T, E>>>,

error_ui: Option<Box<dyn Fn(&mut Ui, &E, &mut State) + Send + Sync>>,
loading_ui: Option<Box<dyn Fn(&mut Ui) + Send + Sync>>,
error_ui: Option<Box<ErrorUiFn<E>>>,
loading_ui: Option<Box<LoadingUiFn>>,
}

impl<T: Debug, E: Display + Debug> Debug for EguiSuspense<T, E> {
Expand Down Expand Up @@ -135,9 +141,9 @@ impl<T: Debug + Send + Sync + 'static, E: Display + Debug + Send + Sync + 'stati
) -> Option<R> {
let mut result = None;

self.inbox.read(ui).last().map(|result| {
if let Some(result) = self.inbox.read(ui).last() {
self.data = Some(result);
});
}

let mut clear_data = false;
let clear_data_ref = &mut clear_data;
Expand Down

0 comments on commit 6b28803

Please sign in to comment.