-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guard types should implement more traits #24372
Comments
Triage: |
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. |
The |
Smart pointers and guards should eagerly implement common traits. 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 |
I'd like to have a go at this one |
As a first pass, I'm looking at ensuring that |
Sounds good! You can also look at things like |
@Mark-Simulacrum |
https://doc.rust-lang.org/std/cell/struct.RefMut.html and https://doc.rust-lang.org/std/cell/struct.Ref.html are RefCell's guards. |
Thanks! |
…excrichton Ensure Guard types impl Display & Debug Fixes rust-lang#24372
…excrichton Ensure Guard types impl Display & Debug Fixes rust-lang#24372
Thanks a bunch @ChrisMacNaughton. I'm reopening this because we also want Eq, PartialEq, Ord, PartialOrd, and Hash for these types. @rust-lang/libs if we implement e.g. That would also seem to call for something like |
I've never been clear on the set of |
What about |
Implements Hash, PartialEq, Eq, PartialOrd, and Ord for Ref, RefMut, MutexGuard, RwLockReadGuard, RwLockWriteGuard Fixes rust-lang#24372
I am closing for now because I believe we are going to hold off on adding more of these impls.
|
What strategy and what are the downside ? Following https://stackoverflow.com/q/66753005/7076153 question. |
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
andDebug
.The text was updated successfully, but these errors were encountered: