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 {