From 8ebf19a5a7eb257865e306e42916a0497f2fbd19 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Sat, 18 Feb 2023 14:22:35 +0100 Subject: [PATCH] Add Clone impl to FixedVec --- narcissus-core/src/fixed_vec.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/narcissus-core/src/fixed_vec.rs b/narcissus-core/src/fixed_vec.rs index d76fcd6..3fb12e5 100644 --- a/narcissus-core/src/fixed_vec.rs +++ b/narcissus-core/src/fixed_vec.rs @@ -108,9 +108,7 @@ impl FixedVec { #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { - panic!( - "swap_remove index (is {index}) should be < len (is {len})" - ); + panic!("swap_remove index (is {index}) should be < len (is {len})"); } let len = self.len(); @@ -133,9 +131,7 @@ impl FixedVec { #[cold] #[inline(never)] fn assert_failed(index: usize, len: usize) -> ! { - panic!( - "insertion index (is {index}) should be <= len (is {len})" - ); + panic!("insertion index (is {index}) should be <= len (is {len})"); } let len = self.len(); @@ -495,6 +491,19 @@ impl FixedVec { } } +impl Clone for FixedVec +where + T: Clone, +{ + fn clone(&self) -> Self { + let mut v = Self::new(); + for i in self { + v.push(i.clone()) + } + v + } +} + impl FixedVec { #[inline] pub fn dedup(&mut self) { -- 2.49.0