From 02821a2aa987a9d2e918d1e6454f7b494d3e10a1 Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 10 Feb 2022 18:35:35 +0000 Subject: [PATCH] Added `completed_{ref,mut}()` methods as pancking complements for `try_completed_{ref,mut}()`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for parapop's current commit: Curse − 凶 --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index beb28e4..9cf5728 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -407,6 +407,26 @@ impl<'a, T> Populator<'a, T> None } } + + /// Returns a slice of all the elements + /// + /// # Panics + /// If the collection was not full. + #[inline] + pub fn completed_ref(&self) -> &[T] + { + self.try_completed_ref().expect("Collection was not fully populated") + } + + /// Returns a mutable slice of all the elements + /// + /// # Panics + /// If the collection was not full. + #[inline] + pub fn completed_mut(&mut self) -> &[T] + { + self.try_completed_mut().expect("Collection was not fully populated") + } /// If all values are populated, returns a mutable slice of all the elements. ///