-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove Deref
and DerefMut
for Json
#2909
Comments
These impls don't exist without precedent:
It appears Actix-web experimented with removing them (on other adapters, anyway) but ultimately decided to keep them: actix/actix-web#2016 (comment) In fact, they actually prefer When you're writing a ton of queries, e.g. for a large backend API, a little bit of convenience goes a long way. I've never had a bug result from these impls existing, nor have I heard of one happening from my coworkers who use SQLx extensively. If you really don't like them, just don't use them. |
@abonander Thanks for taking the time to answer this. I didn't mention this initially, but most of us are aware that impls of Perhaps my (again, opinionated) argument against such I have witnessed occasions when the underlying mechanics of simple wrappers like Relying on Nevertheless, I was certain that the decision to implement these traits was made consciously and I wasn't necessarily expecting that to change simply from me challenging it. I appreciate you explaining the rationale behind the decision. |
Bug Description
Perhaps not a bug, but a questionable implementation decision.
The
Json
newtype wrapper implementsDeref
andDerefMut
along with the more correctAsRef
andAsMut
traits. I'd personally say thatDeref
andDerefMut
should be removed, perhaps in0.8.0
as it would be a breaking change.The rationale is that the impls are arguably redundant and even lead to confusion in some occasions for the sole benefit of a shortcut in field access (which ends up giving references instead of owned types as with regular structs field access).
Minimal Reproduction
Info
rustc --version
: N/AThe text was updated successfully, but these errors were encountered: