1
This commit is contained in:
parent
2f86bbc0ae
commit
8b68ed92b6
@ -14,19 +14,7 @@ pub struct ListHead<T> {
|
||||
|
||||
impl<T> ListHead<T> {
|
||||
|
||||
pub fn new_head() -> Rc::<RefCell::<Self>> {
|
||||
let this = Rc::new(RefCell::new(ListHead{
|
||||
prev: Default::default(),
|
||||
next: Default::default(),
|
||||
data: Default::default(),
|
||||
_self_wp: Default::default(),
|
||||
}));
|
||||
this.borrow_mut()._self_wp = Rc::downgrade(&this);
|
||||
this.borrow_mut().init();
|
||||
return this;
|
||||
}
|
||||
|
||||
pub fn new_node(data: Weak::<RefCell::<T>>) -> Rc::<RefCell::<Self>> {
|
||||
fn new(data: Weak::<RefCell::<T>>) -> Rc::<RefCell::<Self>> {
|
||||
let this = Rc::new(RefCell::new(ListHead{
|
||||
prev: Default::default(),
|
||||
next: Default::default(),
|
||||
@ -38,6 +26,14 @@ impl<T> ListHead<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
pub fn new_head() -> Rc::<RefCell::<Self>> {
|
||||
return Self::new(Default::default());
|
||||
}
|
||||
|
||||
pub fn new_node(data: Weak::<RefCell::<T>>) -> Rc::<RefCell::<Self>> {
|
||||
return Self::new(data);
|
||||
}
|
||||
|
||||
fn init(&mut self) {
|
||||
self.prev = Rc::downgrade(&self.shared_from_self());
|
||||
self.next = Rc::downgrade(&self.shared_from_self());
|
||||
|
Loading…
x
Reference in New Issue
Block a user