diff --git a/src/lib.rs b/src/lib.rs index 0caeabc..e203fd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -457,6 +457,58 @@ where } } +impl FromIterator for Aligned +where + A: Alignment, + T: FromIterator, +{ + fn from_iter>(iter: I) -> Self { + Self { + _alignment: [], + value: T::from_iter(iter), + } + } +} + +impl IntoIterator for Aligned +where + A: Alignment, + T: IntoIterator, +{ + type IntoIter = T::IntoIter; + type Item = T::Item; + + fn into_iter(self) -> Self::IntoIter { + self.value.into_iter() + } +} + +impl<'a, A, T> IntoIterator for &'a Aligned +where + A: Alignment, + &'a T: IntoIterator, +{ + type IntoIter = <&'a T as IntoIterator>::IntoIter; + type Item = <&'a T as IntoIterator>::Item; + + fn into_iter(self) -> Self::IntoIter { + (&self.value).into_iter() + } +} + +impl<'a, A, T> IntoIterator for &'a mut Aligned +where + A: Alignment, + &'a mut T: IntoIterator, +{ + type IntoIter = <&'a mut T as IntoIterator>::IntoIter; + type Item = <&'a mut T as IntoIterator>::Item; + + fn into_iter(self) -> Self::IntoIter { + (&mut self.value).into_iter() + } +} + #[test] fn sanity() { use core::mem;