pub fn new() -> Self {
        // MyLinkedList 的方法全是 &self, 没办法修改 head, tail 的值, 干脆两端都加个虚拟节点算了...
        let ret = MyLinkedList {
            len: Cell::new(0),
            head: Some(Rc::new(RefCell::new(Node::new(0)))),
            tail: Some(Rc::new(RefCell::new(Node::new(0)))),
        };
        ret.head.as_ref().unwrap().borrow_mut().next = ret.tail.clone();
        ret.tail.as_ref().unwrap().borrow_mut().prev = Some(Rc::downgrade(ret.head.as_ref().unwrap()));
        ret
    }
/** Initialize your data structure here. */
Initialize your data structure here.
Initialize your data structure here .
pub fn new() -> Self {
        // MyLinkedList 的方法全是 &self, 没办法修改 head, tail 的值, 干脆两端都加个虚拟节点算了...
        let ret = MyLinkedList {
            len: Cell::new(0),
            head: Some(Rc::new(RefCell::new(Node::new(0)))),
            tail: Some(Rc::new(RefCell::new(Node::new(0)))),
        };
        ret.head.as_ref().unwrap().borrow_mut().next = ret.tail.clone();
        ret.tail.as_ref().unwrap().borrow_mut().prev = Some(Rc::downgrade(ret.head.as_ref().unwrap()));
        ret
    }
pub fn new ( ) -> Self { // MyLinkedList 的方法全是 &self, 没办法修改 head, tail 的值, 干脆两端都加个虚拟节点算了... let ret = MyLinkedList { len : Cell :: new ( 0 ) , head : Some ( Rc :: new ( RefCell :: new ( Node :: new ( 0 ) ) ) ) , tail : Some ( Rc :: new ( RefCell :: new ( Node :: new ( 0 ) ) ) ) , } ; ret . head . as_ref ( ) . unwrap ( ) . borrow_mut ( ) . next = ret . tail . clone ( ) ; ret . tail . as_ref ( ) . unwrap ( ) . borrow_mut ( ) . prev = Some ( Rc :: downgrade ( ret . head . as_ref ( ) . unwrap ( ) ) ) ; ret }
Initialize your data structure here.
Initialize your data structure here .