General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
p11
ThePrimeTime
comments
Comments by "p11" (@porky1118) on "An Optimization That Is Impossible In Rust" video.
34:30 Lifetimes work well in Rust. The trick is just not to use them at all if possible. Or only in structs. And when you use a lifetime in a struct, there has to be a good reason for it. The best reason I came across is when you want to create some temporary type T, which has mutable access to some other type O, forbidding the user to access the value of type O as long as a value of type T exists. In my case it was some edit struct T, which enables editing O safely. Because after editing, the states have to be updated. So the safe way to edit is using a value of type T. And the drop method of T updates the states of O. And only after T has been dropped, the user can access O directly again, which will be in a safe state again.
3
28:24 I just disabled this lint altogether. I guess it isn't even enabled by default when using clippy.
1