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-11-09 17:47:05 +01:00
committed by cloudhead
parent 559f84d9f1
commit 92f21d7f29
+6
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)