From fb8a31a88f76492dd17d8bcdaeead94af77e813f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 4 Dec 2022 00:02:15 -0500 Subject: [PATCH] I think I solved the clone issue by manually implementing clone since the Rc needs to be cloned, not the content inside it. --- src/parser/list.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/parser/list.rs b/src/parser/list.rs index aec0af83..2806448d 100644 --- a/src/parser/list.rs +++ b/src/parser/list.rs @@ -1,10 +1,18 @@ use std::rc::Rc; -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct List { head: Option>>, } +impl Clone for List { + fn clone(&self) -> Self { + List { + head: self.head.clone(), + } + } +} + #[derive(Debug, Clone)] pub struct Node { data: T, @@ -27,7 +35,7 @@ impl List { pub fn without_front(&self) -> List { List { - head: self.head.as_ref().map(|node| node.parent.clone()).flatten() + head: self.head.as_ref().map(|node| node.parent.clone()).flatten(), } }