too-many-lists/bad-stack/final-code #912
Replies: 6 comments 5 replies
-
直呼:安全!安全! |
Beta Was this translation helpful? Give feedback.
-
Another solution for drop() impl Drop for List {
fn drop(&mut self) {
let mut cur_link = mem::replace(&mut self.head, Link::Empty);
while let Link::More(boxed_node) = cur_link {
cur_link = boxed_node.next; // ownership transfer
} // boxed_node auto drop
}
} |
Beta Was this translation helpful? Give feedback.
-
这里是因为吧
|
Beta Was this translation helpful? Give feedback.
-
你这个模拟编译器是啥?我也想看看我编写的代码drop怎么实现的 |
Beta Was this translation helpful? Give feedback.
-
我想问问: |
Beta Was this translation helpful? Give feedback.
-
This destructor consists of two components:
A call to Drop::drop for that value, if this special Drop trait is implemented for its type.
The automatically generated “drop glue” which recursively calls the destructors of all the fields of this value.
Reference: https://doc.rust-lang.org/std/ops/trait.Drop.html
…----------
该邮件从移动设备发送
--------------原始邮件--------------
发件人:"Ryuzu ***@***.***>;
发送时间:2023年2月1日(星期三) 下午3:29
收件人:"sunface/rust-course" ***@***.***>;
抄送:"GeniusPenguin9 ***@***.***>;"Comment ***@***.***>;
主题:Re: [sunface/rust-course] too-many-lists/bad-stack/final-code (Discussion #912)
-----------------------------------
也就是说我们自己实现的drop并不会覆盖原来编译器默认实现的drop?
相当于在之前加了一层调用函数?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
too-many-lists/bad-stack/final-code
https://course.rs/too-many-lists/bad-stack/final-code.html
Beta Was this translation helpful? Give feedback.
All reactions