mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Add regression test for #12964
This commit is contained in:
parent
567bea29b1
commit
ba05b764bc
1 changed files with 39 additions and 0 deletions
|
@ -185,3 +185,42 @@ pub mod issue11635 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod issue12964 {
|
||||
pub struct MyIter<'a, T: 'a> {
|
||||
iter: std::slice::Iter<'a, T>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for MyIter<'a, T> {
|
||||
type Item = &'a T;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.iter.next()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MyContainer<T> {
|
||||
inner: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T> MyContainer<T> {}
|
||||
|
||||
impl<T> MyContainer<T> {
|
||||
#[must_use]
|
||||
pub fn iter(&self) -> MyIter<'_, T> {
|
||||
<&Self as IntoIterator>::into_iter(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> IntoIterator for &'a MyContainer<T> {
|
||||
type Item = &'a T;
|
||||
|
||||
type IntoIter = MyIter<'a, T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
Self::IntoIter {
|
||||
iter: self.inner.as_slice().iter(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue