From a329cabce481c022ff797ba914ab6a47034d26ec Mon Sep 17 00:00:00 2001 From: StarStarJ Date: Fri, 13 Dec 2024 14:14:14 +0100 Subject: [PATCH] Add `len` & `is_empty` functions --- CHANGELOG.md | 2 ++ src/lib.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a495c2..5b29291 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +* Add `len` & `is_empty` functions + # 0.17.0 * (breaking) removed `Toast::font(font: FontId)`, this can now be done by using `egui::widget_text::RichText` and `RichText::font`. [#34] * Added support for `egui::widget_text::WidgetText` in Toasts, this allows for more customization of the text in the toast. [#34] diff --git a/src/lib.rs b/src/lib.rs index 076718b..a5a33c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,6 +103,16 @@ impl Toasts { } } + /// Returns the number of toast items. + pub fn len(&self) -> usize { + self.toasts.len() + } + + /// Returns `true` if there are no toast items. + pub fn is_empty(&self) -> bool { + self.toasts.is_empty() + } + /// Shortcut for adding a toast with info `success`. pub fn success(&mut self, caption: impl Into) -> &mut Toast { self.add(Toast::success(caption))