From 1f776e7ff9df1dd2fa34c370f9a84bd8f9ba5173 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 27 Sep 2023 10:47:32 +0200 Subject: [PATCH] Add `Handles::first` --- crates/fj-core/src/objects/handles.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/fj-core/src/objects/handles.rs b/crates/fj-core/src/objects/handles.rs index eb4085ebc..4db5a5cd0 100644 --- a/crates/fj-core/src/objects/handles.rs +++ b/crates/fj-core/src/objects/handles.rs @@ -80,6 +80,17 @@ impl Handles { item } + /// Return the first item + /// + /// # Panics + /// + /// Panics, if there are no items. + pub fn first(&self) -> &Handle { + self.inner + .first() + .expect("Requested first item, but no items available") + } + /// Return the n-th item pub fn nth(&self, index: usize) -> Option<&Handle> { self.inner.get(index)