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:
parent
559f84d9f1
commit
92f21d7f29
|
|
@ -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> {
|
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 {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
self.v.fmt(f)
|
self.v.fmt(f)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue