|
|
|
|
|
by CyberDildonics
3719 days ago
|
|
Keep in mind that when you have a dll you are unloading instructions, not data. Also C++ has unique_ptr that also tracks lifetimes, I don't think Rust would really give you anything you don't already have and I think you are overestimating the fragility. I've done hot reloading of .dll and it isn't really all that fragile. If you have the c runtime as a dynamic .dll the heap won't be tied to the .dll either. |
|
For example, this Rust program:
Is caught at compile time. Rust keeps track of the lifetime of both b and r, and knows that r will be dangling.The C++ version:
This compiles with no warnings under -Wall -Wextra with no warnings, and happily does whatever you ask with r, even though it's dangling.Yes, this specific example is a bit contrived, but such is the way of examples. My point is just that C++'s smart pointers are a great thing, but that doesn't mean they do everything that Rust's do.