Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
protocol: IntoIterator for BoundedVec
Merged fintohaps opened 4 months ago

Implement IntoIterator for the BoundedVec.

This allows the use of into_iter for returning the owned data, rather than references via the Deref implementation.

1 file changed +9 -0 37d4ae4a c675683d
modified crates/radicle-protocol/src/bounded.rs
@@ -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];