diff --git a/src/list.rs b/src/list.rs index 92c777e..42feff5 100644 --- a/src/list.rs +++ b/src/list.rs @@ -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) } }