too-many-lists/persistent-stack/layout #892
Replies: 8 comments 9 replies
-
求 iterMut 实现,已投降 - -! |
Beta Was this translation helpful? Give feedback.
-
感觉先去看一遍《通过例子学Rust》再来看这个例子比较好,现在看的有点懵 |
Beta Was this translation helpful? Give feedback.
-
pub fn prepend(&self, elem: T) -> List { |
Beta Was this translation helpful? Give feedback.
-
这里做个小分析,纯粹是个人填下之前没有完全理解的坑; self.head.as_ref() => Option<&Rc<Node> map desugaring => and_then desugaring => 嵌套的Option应该是由于map返回的类型为LInk /* Option<Rc<Node>>*/; 本质上是符合官方对两个方法的定义: |
Beta Was this translation helpful? Give feedback.
-
未经充分测试,简单测试是通过的 IntoIter
IterMut
|
Beta Was this translation helpful? Give feedback.
-
我有个疑问:为什么tail方法移除元素时,要用clone()方法?这不是会让强引用数+1吗?是和drop方法有关吗?
当list中的所有节点tail之后,list2中的7-6-5-3-2-1的强引用依次是:1-1-1-2-2-2 |
Beta Was this translation helpful? Give feedback.
-
这个开头提出的数据布局我居然都没操作出来 |
Beta Was this translation helpful? Give feedback.
-
对列表进行迭代时,将 pub struct Iter<'a, T> {
next: Option<&'a Rc<Node<T>>>,
} |
Beta Was this translation helpful? Give feedback.
-
too-many-lists/persistent-stack/layout
https://course.rs/too-many-lists/persistent-stack/layout.html
Beta Was this translation helpful? Give feedback.
All reactions