Skip to content

Commit

Permalink
Merge pull request #35 from StarStarJ/pr_len
Browse files Browse the repository at this point in the history
Add `len` & `is_empty` functions
  • Loading branch information
ItsEthra authored Dec 14, 2024
2 parents a258986 + a329cab commit 8633808
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 8633808

Please sign in to comment.