Skip to content

Commit

Permalink
Added trait
Browse files Browse the repository at this point in the history
  • Loading branch information
mqxf committed Jan 9, 2024
1 parent a184859 commit 39566f6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ use scale_info::{
#[derive(Clone, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Decode, Encode, TypeInfo)]
pub struct LimitedVec<T, E, const N: usize>(Vec<T>, PhantomData<E>);

impl<T, E, const M: usize, const N: usize> From<[T; M]> for LimitedVec<T, E, N> {
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<T: Clone + Default, E: Default, const N: usize> Display for LimitedVec<T, E, N>
where
Expand Down

0 comments on commit 39566f6

Please sign in to comment.