|
|
|
|
|
by pkolaczk
1830 days ago
|
|
And what did you try to prove here? There is no use after free and no runtime error in this rust code. The socket stays valid since the moment of its creation and for the whole lifetime of the network component. It gets moved out of nested scope properly and gets closed after leaving the outer scope, after dropping the NetworkComponent struct. The "oops" comment is invalid in your Rust example because the socket is still valid at that point. Which is totally different than what would happen in C#, where you'd get use-after-free bug (actually use-after-close). Try with resources is not RAII. It is a lot weaker. |
|
Happens just as well in Rust, why do you think I gave you a Playground link.
If you want, I can shut up the cleverness with a cargo build example instead of a dummy playground example.