From 1e7207c23015f5bb8d9c22db30ccbb3669a9540a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 25 Oct 2024 19:53:08 +0000 Subject: [PATCH] start an ArrayVec extension trait Signed-off-by: Jason Volk --- src/core/utils/arrayvec.rs | 15 +++++++++++++++ src/core/utils/mod.rs | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 src/core/utils/arrayvec.rs diff --git a/src/core/utils/arrayvec.rs b/src/core/utils/arrayvec.rs new file mode 100644 index 00000000..685aaf18 --- /dev/null +++ b/src/core/utils/arrayvec.rs @@ -0,0 +1,15 @@ +use ::arrayvec::ArrayVec; + +pub trait ArrayVecExt { + fn extend_from_slice(&mut self, other: &[T]) -> &mut Self; +} + +impl ArrayVecExt for ArrayVec { + #[inline] + fn extend_from_slice(&mut self, other: &[T]) -> &mut Self { + self.try_extend_from_slice(other) + .expect("Insufficient buffer capacity to extend from slice"); + + self + } +} diff --git a/src/core/utils/mod.rs b/src/core/utils/mod.rs index 8e29c608..26b0484e 100644 --- a/src/core/utils/mod.rs +++ b/src/core/utils/mod.rs @@ -1,3 +1,4 @@ +pub mod arrayvec; pub mod bool; pub mod bytes; pub mod content_disposition; @@ -22,6 +23,7 @@ pub use ::conduit_macros::implement; pub use ::ctor::{ctor, dtor}; pub use self::{ + arrayvec::ArrayVecExt, bool::BoolExt, bytes::{increment, u64_from_bytes, u64_from_u8, u64_from_u8x8}, debug::slice_truncated as debug_slice_truncated,