Skip to content
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

Auto-implement ConnectionLike for DerefMut #567

Merged
merged 1 commit into from May 23, 2022

Conversation

holmesmr
Copy link
Contributor

@holmesmr holmesmr commented Dec 16, 2021

This provides an implementation of ConnectionLike for any type that can be mutably and immutably dereferenced to an implementation of ConnectionLike through DerefMut. The primary motivation is being able to use r2d2::PoolConnections directly to satisfy ConnectionLike, which makes code using pooled connections easier
to read. A blanket impl for r2d2::PoolConnection would suffice for this case, but this is more generalised as not to be r2d2 specific, which would also make it usable for other storage types providing DerefMut.

This provides an implementation of `ConnectionLike` for any type that
can be mutably and immutably dereferenced to an implementation of
`ConnectionLike` through `DerefMut`. The primary motivation is being
able to use `r2d2::PoolConnection`s directly to satisfy
`ConnectionLike`, which makes code using pooled connections easier
to read. A blanket impl for `r2d2::PoolConnection` would suffice but
this is more generalised as not to be r2d2 specific.
@holmesmr holmesmr changed the title Auto-implement ConnectionLike for Deref + DerefMut Auto-implement ConnectionLike for DerefMut Dec 16, 2021
@holmesmr
Copy link
Contributor Author

Apologies - revised this PR as I remembered immediately after opening that DerefMut implies Deref already 😅

Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jaymell jaymell merged commit b331ba2 into redis-rs:main May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants