appendix/derive #775
Replies: 3 comments 5 replies
-
derive is attribute |
Beta Was this translation helpful? Give feedback.
0 replies
-
我看文档,说 然后这里又说,实现 这里有点困惑:
|
Beta Was this translation helpful? Give feedback.
5 replies
-
Clone 和 Copy 那里,实现 Copy 就必须实现 Clone 了。这里怎么还说 实际上 Copy 特征并不阻止你在实现时使用了深拷贝,只是,我们不应该这么做,毕竟遵循一个语言的惯例是很重要的。当用户看到 Copy 时,潜意识就应该知道这是浅拷贝,复制一个值会非常快。 难道实现 Clone 特征过程中还能避免使用深拷贝吗? 我理解其实所有的拷贝其实都是深拷贝,区别只是实现 Copy 特征的(如 i32)发生于栈上的拷贝。以及实现了 Clone 特征的(如 String)发生于堆上数据(实际 value)和栈上的(String 指针) 同时拷贝。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
appendix/derive
https://course.rs/appendix/derive.html
Beta Was this translation helpful? Give feedback.
All reactions