Fix using references for context elements.

This commit is contained in:
Tom Alexander
2023-09-02 22:44:21 -04:00
parent c309d14776
commit ba57eb16fd
3 changed files with 22 additions and 38 deletions

View File

@@ -31,14 +31,8 @@ impl<'parent, T> List<'parent, T> {
pub fn iter_list(&self) -> IterList<'_, T> {
IterList { next: Some(self) }
}
}
pub trait ListType<'parent, T> {
fn push(&'parent self, item: T) -> List<'parent, T>;
}
impl<'parent, T> ListType<'parent, T> for List<'parent, T> {
fn push(&'parent self, item: T) -> Self {
pub fn push(&'parent self, item: T) -> Self {
Self {
data: item,
parent: Some(self),
@@ -46,15 +40,6 @@ impl<'parent, T> ListType<'parent, T> for List<'parent, T> {
}
}
impl<'parent, T> ListType<'parent, T> for Link<'parent, T> {
fn push(&'parent self, item: T) -> List<'parent, T> {
List {
data: item,
parent: *self,
}
}
}
pub struct Iter<'a, T> {
next: Link<'a, T>,
}