From 39566f6f6a29e45eb89fb238a6207cf750065c05 Mon Sep 17 00:00:00 2001 From: mqxf Date: Tue, 9 Jan 2024 13:04:55 +0100 Subject: [PATCH] Added trait --- core/src/buffer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/buffer.rs b/core/src/buffer.rs index e69ece89fb6..843421afdc7 100644 --- a/core/src/buffer.rs +++ b/core/src/buffer.rs @@ -37,6 +37,13 @@ use scale_info::{ #[derive(Clone, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Decode, Encode, TypeInfo)] pub struct LimitedVec(Vec, PhantomData); +impl From<[T; M]> for LimitedVec { + fn from(value: [T; M]) -> Self { + assert!(M <= N); + Self(value.into(), Default::default()) + } +} + /// Formatter for [`LimitedVec`] will print to precision of 8 by default, to print the whole data, use `{:+}`. impl Display for LimitedVec where