Ah, well, ..., this list is longer than I’ve asked for. Also a disclaimer, I’ve myself not really used Rust in practice in an actual bigger project yet, so I wouldn’t really know for sure how many of these would be handled in Rust idiomatically. Some of the things on your list also are still pretty abstract and without context they seem rather pointless and it isn’t clear why they’re actually relevant, for example
or
But there are lots of things that are concrete, too, so I’ll ignore those abstract ones ^^
The main point in Rust safety actually is that API’s would usually (if possible) be done in such a way that it is impossible to forget cleaning up.
I think this is one of the best examples to start getting into that idea. Try taking a look into Rust’s Mutex type which offers exclusive access to some shared data in a way where you cannot accidentally forget releasing the lock, perhaps similar as C++’s unique_lock works, utilizing RAII.
Also your examples regarding allocation usually wouldn’t apply to Rust as you’d be using RAII interfaces like Box there, too; accidentally forgetting to free memory is hard with the standard library. Even further, manually de-allocating things is actually not really possible in Rust without going into unsafe Rust since doing that twice would be a double-free that safe Rust guarantees never happens.
I won’t say there’s never the need for something like janitory, after all someone created the scopeguard crate for a reason, but I guess the general gist of how Rust tries to make things safer is by avoiding the need of manual cleanup all-together in many places. (After all, using janitors could easily be forgotten, too.)
Also let’s not turn this thread into a Rust language tutorial xD