1

看了几天 rust, 总结了一句话关于生命周期

 1 year ago
source link: https://www.v2ex.com/t/936977
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

看了几天 rust, 总结了一句话关于生命周期

  iorilu · 10 小时 7 分钟前 via Android · 2540 次点击
这个生命周期概念确实是 rust 独有

虽然这个理论并不新鲜, 但 rust 是强制,作为程序员必须明确知道所有变量或对象的生命周期,而不是靠编译器或语言自己推理

我总就一句话就是

这里我指一个复杂对象,里面可以有对别的对象引用

借我钱意思是引用我

我借别人钱意思是引用别人

所有借我钱的必须死我前面,这样我就能收回所有借出的钱

但我借别人钱我得死别人前面,这样就不用还钱

这样才能利益最大化啊。。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK