From: Joshua Simmons Date: Sat, 18 Feb 2023 13:22:35 +0000 (+0100) Subject: Add Clone impl to FixedVec X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=8ebf19a5a7eb257865e306e42916a0497f2fbd19;p=josh%2Fnarcissus Add Clone impl to FixedVec --- 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) {