mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Implement more IntoIter traits for bounded types (#11616)
This commit is contained in:
@@ -252,6 +252,24 @@ impl<K, V, S> IntoIterator for BoundedBTreeMap<K, V, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V, S> IntoIterator for &'a BoundedBTreeMap<K, V, S> {
|
||||
type Item = (&'a K, &'a V);
|
||||
type IntoIter = sp_std::collections::btree_map::Iter<'a, K, V>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V, S> IntoIterator for &'a mut BoundedBTreeMap<K, V, S> {
|
||||
type Item = (&'a K, &'a mut V);
|
||||
type IntoIter = sp_std::collections::btree_map::IterMut<'a, K, V>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, S> MaxEncodedLen for BoundedBTreeMap<K, V, S>
|
||||
where
|
||||
K: MaxEncodedLen,
|
||||
|
||||
@@ -230,6 +230,15 @@ impl<T, S> IntoIterator for BoundedBTreeSet<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, S> IntoIterator for &'a BoundedBTreeSet<T, S> {
|
||||
type Item = &'a T;
|
||||
type IntoIter = sp_std::collections::btree_set::Iter<'a, T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S> MaxEncodedLen for BoundedBTreeSet<T, S>
|
||||
where
|
||||
T: MaxEncodedLen,
|
||||
|
||||
@@ -149,6 +149,14 @@ impl<'a, T, S> From<BoundedSlice<'a, T, S>> for &'a [T] {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, S> sp_std::iter::IntoIterator for BoundedSlice<'a, T, S> {
|
||||
type Item = &'a T;
|
||||
type IntoIter = sp_std::slice::Iter<'a, T>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Decode, S: Get<u32>> Decode for BoundedVec<T, S> {
|
||||
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
|
||||
let inner = Vec::<T>::decode(input)?;
|
||||
@@ -605,6 +613,22 @@ impl<T, S> sp_std::iter::IntoIterator for BoundedVec<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, S> sp_std::iter::IntoIterator for &'a BoundedVec<T, S> {
|
||||
type Item = &'a T;
|
||||
type IntoIter = sp_std::slice::Iter<'a, T>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, S> sp_std::iter::IntoIterator for &'a mut BoundedVec<T, S> {
|
||||
type Item = &'a mut T;
|
||||
type IntoIter = sp_std::slice::IterMut<'a, T>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S> codec::DecodeLength for BoundedVec<T, S> {
|
||||
fn len(self_encoded: &[u8]) -> Result<usize, codec::Error> {
|
||||
// `BoundedVec<T, _>` stored just a `Vec<T>`, thus the length is at the beginning in
|
||||
|
||||
@@ -262,6 +262,22 @@ impl<T, S> sp_std::iter::IntoIterator for WeakBoundedVec<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, S> sp_std::iter::IntoIterator for &'a WeakBoundedVec<T, S> {
|
||||
type Item = &'a T;
|
||||
type IntoIter = sp_std::slice::Iter<'a, T>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, S> sp_std::iter::IntoIterator for &'a mut WeakBoundedVec<T, S> {
|
||||
type Item = &'a mut T;
|
||||
type IntoIter = sp_std::slice::IterMut<'a, T>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S> codec::DecodeLength for WeakBoundedVec<T, S> {
|
||||
fn len(self_encoded: &[u8]) -> Result<usize, codec::Error> {
|
||||
// `WeakBoundedVec<T, _>` stored just a `Vec<T>`, thus the length is at the beginning in
|
||||
|
||||
Reference in New Issue
Block a user