Skip to content

Commit

Permalink
Add len & is_empty functions
Browse files Browse the repository at this point in the history
  • Loading branch information
StarStarJ committed Dec 13, 2024
1 parent a258986 commit a329cab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WidgetText>) -> &mut Toast {
self.add(Toast::success(caption))
Expand Down

0 comments on commit a329cab

Please sign in to comment.