From ee4b5991a5a81a78657e9a6dfce9130bfdb46db6 Mon Sep 17 00:00:00 2001 From: Sean Olson Date: Tue, 23 Jul 2024 16:56:20 -0700 Subject: [PATCH] Implement `insert` for `ArrayVec1`. --- src/array_vec1.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/array_vec1.rs b/src/array_vec1.rs index 9a2b3ee..4ddf3ca 100644 --- a/src/array_vec1.rs +++ b/src/array_vec1.rs @@ -186,6 +186,10 @@ where self.many_or_get_only(|items| unsafe { items.pop().unwrap_maybe_unchecked() }) } + pub fn insert(&mut self, index: usize, item: T) { + self.items.insert(index, item) + } + pub fn insert_or_get_last(&mut self, index: usize, item: T) -> Result<(), (T, &T)> { self.vacant_or_get_last(item, move |item, items| items.insert(index, item)) }