protocol: IntoIterator for BoundedVec

Implement `IntoIterator` for the `BoundedVec`.

This allows the use of `into_iter` for returning the owned data,
rather than references via the `Deref` implementation.
This commit is contained in:
Fintan Halpenny 2025-08-27 09:24:48 +01:00
parent 37d4ae4a9f
commit c675683da9
1 changed files with 9 additions and 0 deletions

View File

@ -180,6 +180,15 @@ impl<T: Clone, const N: usize> BoundedVec<T, N> {
}
}
impl<T, const N: usize> IntoIterator for BoundedVec<T, N> {
type Item = T;
type IntoIter = std::vec::IntoIter<T>;
fn into_iter(self) -> Self::IntoIter {
self.v.into_iter()
}
}
impl<T, const N: usize> ops::Deref for BoundedVec<T, N> {
type Target = [T];