From e18f98181cf40f0c231d2764d26e7c2babc4a506 Mon Sep 17 00:00:00 2001 From: Tony4dev Date: Fri, 24 Jan 2025 22:06:18 +0100 Subject: [PATCH] Segmented button model - add convenience method to get number of items in the model. --- src/widget/segmented_button/model/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/widget/segmented_button/model/mod.rs b/src/widget/segmented_button/model/mod.rs index 449c829fb47..c24fe85f13a 100644 --- a/src/widget/segmented_button/model/mod.rs +++ b/src/widget/segmented_button/model/mod.rs @@ -310,6 +310,11 @@ where self.items.get(id).map_or(false, |e| e.enabled) } + /// Get number of items in the model. + pub fn len(&self) -> usize { + self.order.len() + } + /// Iterates across items in the model in the order that they are displayed. pub fn iter(&self) -> impl Iterator + '_ { self.order.iter().copied()