diff --git a/README.md b/README.md index cc70573..41d5832 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ let mut toasts = Toasts::default(); ```rust // somewhere within [egui::App::update]... -toasts.info("Hello world!").set_duration(Duration::from_secs(5)); +toasts.info("Hello world!").set_duration(Some(Duration::from_secs(5))); // ... toasts.show(ctx); ``` diff --git a/src/lib.rs b/src/lib.rs index 4239153..783f8b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ const SUCCESS_COLOR: Color32 = Color32::from_rgb(140, 230, 140); /// /// # egui_notify::__run_test_ctx(|ctx| { /// let mut t = Toasts::default(); -/// t.info("Hello, World!").set_duration(Some(Duration::from_secs(5))).set_closable(true); +/// t.info("Hello, World!").set_duration(Duration::from_secs(5)).set_closable(true); /// // More app code /// t.show(ctx); /// # }); diff --git a/src/toast.rs b/src/toast.rs index c0c555a..0530c07 100644 --- a/src/toast.rs +++ b/src/toast.rs @@ -205,8 +205,8 @@ impl Toast { } /// In what time should the toast expire? Set to `None` for no expiry. - pub fn set_duration(&mut self, duration: Option) -> &mut Self { - if let Some(duration) = duration { + pub fn set_duration(&mut self, duration: impl Into>) -> &mut Self { + if let Some(duration) = duration.into() { let max_dur = duration_to_seconds_f32(duration); self.duration = Some((max_dur, max_dur)); } else {