4 ms·
This is kind of an area where rust could maybe benefit from being a bit more monadic imo. It would be nice if you could have the MutexGuard object wrap return v
by stormbrew 4y ago
This is kind of an area where rust could maybe benefit from being a bit more monadic imo. It would be nice if you could have the MutexGuard object wrap return values of functions called through its AsRef/AsMut impls in a (potentially moved) MutexGuard themselves, so that instead of it relying on borrows and lifetimes to hold the lock it would be the type system itself. I think there's some downsides to this approach, but I've run into other situations where it would have been nice to be able to do this.
I don't believe it's possible with the language as-is though.