From 8f1497df8360888dfd1b0d44148cea90ddf4ad01 Mon Sep 17 00:00:00 2001 From: David Mak Date: Wed, 27 Mar 2024 12:10:22 +0800 Subject: [PATCH] core/helper: Add PrimitiveDefinitionIds::iter --- nac3core/src/toplevel/helper.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nac3core/src/toplevel/helper.rs b/nac3core/src/toplevel/helper.rs index 2180d16eb..e212ac8b5 100644 --- a/nac3core/src/toplevel/helper.rs +++ b/nac3core/src/toplevel/helper.rs @@ -45,10 +45,15 @@ impl PrimitiveDefinitionIds { ] } + /// Returns an iterator over all [`DefinitionId`]s of this instance in indeterminate order. + pub fn iter(&self) -> impl Iterator { + self.as_vec().into_iter() + } + /// Returns the primitive with the largest [`DefinitionId`]. #[must_use] pub fn max_id(&self) -> DefinitionId { - self.as_vec().into_iter().max().unwrap() + self.iter().max().unwrap() } }