Open ericseppanen opened 2 years ago
List has fields data and next, but in the impl Clone it says value and next.
List
data
next
impl Clone
value
#[derive(Clone)] struct List<T> { data: Rc<T>, next: Option<Rc<List<T>>>, } impl<T> Deref for List<T> { type Target = T; fn deref(&self) -> &T { &self.data } } Currently, derive is going to generate an impl that requires T: Clone, like this… impl<T> Clone for List<T> where T: Clone, { fn clone(&self) { List { value: self.value.clone(), next: self.next.clone(), } } }
#[derive(Clone)] struct List<T> { data: Rc<T>, next: Option<Rc<List<T>>>, } impl<T> Deref for List<T> { type Target = T; fn deref(&self) -> &T { &self.data } }
Currently, derive is going to generate an impl that requires T: Clone, like this…
T: Clone
impl<T> Clone for List<T> where T: Clone, { fn clone(&self) { List { value: self.value.clone(), next: self.next.clone(), } } }
Thanks
List
has fieldsdata
andnext
, but in theimpl Clone
it saysvalue
andnext
.