Add map method to MutexGuard, RwLockReadGuard, RwLockWriteGuard #2471
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-sync
Module: tokio/sync
Thanks for such an excellent crate! I'm really enjoying using it and it's very well documented. 😄
Version
tokio v0.2.20
Description
The
parking_lot
crate provides amap
method onMutexGuard
,RwLockReadGuard
,RwLockWriteGuard
that is very convenient when you need to return some part of a locked value. For example, this can be used to implement a method that return a reference to a single field of a value that you previously locked.MutexGuard::map
RwLockReadGuard::map
RwLockWriteGuard::map
Would it be possible for tokio to add these methods to its lock guards? Are there any major complications that could be encountered due to async or because of the mutex implementation?
I'd be willing to work on this if no one else is available. (Though I would not object if someone else is willing to take this on.)
The text was updated successfully, but these errors were encountered: