changed impl

This commit is contained in:
Erin 2022-07-21 12:16:39 +02:00 committed by ondra05
parent e5e192a142
commit 09df88c80d

View file

@ -1,3 +1,5 @@
use std::fmt::Display;
use crate::value::Value; use crate::value::Value;
/// Single-linked list /// Single-linked list
@ -14,8 +16,13 @@ impl<'a> List<'a> {
.rev() .rev()
.fold(Self::Nil, |list, next| Self::Cons(next, Box::new(list))) .fold(Self::Nil, |list, next| Self::Cons(next, Box::new(list)))
} }
}
pub fn iter(&self) -> Iter<'_, '_> { impl<'l, 'v> IntoIterator for &'l List<'v> {
type Item = &'l Value<'v>;
type IntoIter = Iter<'l, 'v>;
fn into_iter(self) -> Self::IntoIter {
Iter(self) Iter(self)
} }
} }