From 77b3f3751c02803890c81435e0417607d5f8df03 Mon Sep 17 00:00:00 2001 From: Eduard Knyshov Date: Wed, 28 Aug 2024 23:18:56 +0700 Subject: [PATCH] make to_duration accept Int> --- src/lib.rs | 2 +- src/toast.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 {