You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Types like std::sync::MutexGuard are semantically just a &mut with a destructor, and so it makes sense for them to implement the same sort of traits, e.g. Display and Debug.
@rust-lang/libs: This seems relevant to libz blitz, we probably want to work out some guidelines for wrapper types like this (what traits they should "forward"). For example, I can't think of a good Display implementation for MutexGuard, but perhaps there is one.
To an extent, it could be argued that most if not all std traits should be forwarded through types like MutexGuard, but this feels like it gets painful very quickly.
Smart pointers and guards should eagerly implement common traits. Debug at least should be transparent, custom implemented to defer to the inner type. Not clear whether Eq/Ord should be implemented against the inner type.
Next step here is to identify such types in std and file a PR.
Activity
steveklabnik commentedon Jun 27, 2016
Triage:
MutexGuard
does not implement those traits today.Mark-Simulacrum commentedon Jun 15, 2017
Debug is implemented today, but not Display.
@rust-lang/libs: This seems relevant to libz blitz, we probably want to work out some guidelines for wrapper types like this (what traits they should "forward"). For example, I can't think of a good Display implementation for MutexGuard, but perhaps there is one.
To an extent, it could be argued that most if not all std traits should be forwarded through types like MutexGuard, but this feels like it gets painful very quickly.
sfackler commentedon Jun 15, 2017
The
Display
impl forMutexGuard
would just delegate to the inner value'sDisplay
.brson commentedon Jun 20, 2017
Smart pointers and guards should eagerly implement common traits.
Debug
at least should be transparent, custom implemented to defer to the inner type. Not clear whether Eq/Ord should be implemented against the inner type.Next step here is to identify such types in std and file a PR.
Here's an issue for the guidelines: rust-lang/api-guidelines#94
[-]Guard types in std::sync should implement more traits[/-][+]Guard types should implement more traits[/+]ChrisMacNaughton commentedon Jun 22, 2017
I'd like to have a go at this one
ChrisMacNaughton commentedon Jun 22, 2017
As a first pass, I'm looking at ensuring that
MutexGuard
,RwLockReadGuard
, andRwLockWriteGuard
implDisplay
andDebug
. How does that sound?23 remaining items