node: add conversion for BoundedVec to Vec

While there is a method, `unbound`, for converting a `BoundedVec` to
its inner `Vec`, it is common practice to implement the `From` trait.

Add the `From` conversion for `BoundedVec` and `Vec`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-10-19 10:13:21 +01:00 committed by cloudhead
parent 559f84d9f1
commit 92f21d7f29
No known key found for this signature in database
1 changed files with 6 additions and 0 deletions

View File

@ -189,6 +189,12 @@ impl<T, const N: usize> TryFrom<Vec<T>> for BoundedVec<T, N> {
}
}
impl<T, const N: usize> From<BoundedVec<T, N>> for Vec<T> {
fn from(value: BoundedVec<T, N>) -> Self {
value.v
}
}
impl<T: std::fmt::Debug, const N: usize> std::fmt::Debug for BoundedVec<T, N> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.v.fmt(f)