changed impl

main
ondra05 2022-07-21 12:16:39 +02:00
parent 4a4aca2366
commit 7982c8ca4f
1 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,5 @@
use std::fmt::Display;
use crate::value::Value;
/// Single-linked list
@ -14,8 +16,13 @@ impl<'a> List<'a> {
.rev()
.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)
}
}