pub mod prelude;
pub trait IterRef: IntoIterator {
type IntoIterRef<'a>: Iterator<Item = &'a Self::Item> where Self: 'a;
fn iter<'a>(&'a self) -> Self::IntoIterRef<'a>;
}
pub trait IterRefMut: IntoIterator {
type IntoIterRefMut<'a>: Iterator<Item = &'a mut Self::Item> where Self: 'a;
fn iter_mut<'a>(&'a mut self) -> Self::IntoIterRefMut<'a>;
}
impl<T: IntoIterator> IterRef for T
where for<'a> &'a T: IntoIterator<Item = &'a T::Item>
{
type IntoIterRef<'a> = <&'a Self as IntoIterator>::IntoIter where T: 'a;
fn iter<'a>(&'a self) -> <&'a Self as IntoIterator>::IntoIter {
self.into_iter()
}
}
impl<T: IntoIterator> IterRefMut for T
where
for<'a> &'a Self: IntoIterator<Item = &'a<Self as IntoIterator>::Item>,
for<'a> &'a mut Self: IntoIterator<Item = &'a mut <Self as IntoIterator>::Item>,
{
type IntoIterRefMut<'a> = <&'a mut Self as IntoIterator>::IntoIter where T: 'a;
fn iter_mut<'a>(&'a mut self) -> <&'a mut Self as IntoIterator>::IntoIter {
self.into_iter()
}
}