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

Make connection_like::ToConnection public #251

Open
Wasabi375 opened this issue Jul 31, 2023 · 0 comments
Open

Make connection_like::ToConnection public #251

Wasabi375 opened this issue Jul 31, 2023 · 0 comments

Comments

@Wasabi375
Copy link

I don't really understand why ToConnection is an empty trait that requires connection_like::ToConnection to be implemented.

// src/lib.rs:575-584
/// Everything that is a connection.
///
/// Note that you could obtain a `'static` connection by giving away `Conn` or `Pool`.
pub trait ToConnection<'a, 't: 'a>: crate::connection_like::ToConnection<'a, 't> {}
// explicitly implemented because of rusdoc
impl<'a> ToConnection<'a, 'static> for &'a crate::Pool {}
impl<'a> ToConnection<'static, 'static> for crate::Pool {}
impl ToConnection<'static, 'static> for crate::Conn {}
impl<'a> ToConnection<'a, 'static> for &'a mut crate::Conn {}
impl<'a, 't> ToConnection<'a, 't> for &'a mut crate::Transaction<'t> {}

Because connection_like is a private module it is impossible for anyone to add additional implementations for ToConnection.
One usecase for that would be a simple wrapper type, e.g. to distinguish between 2 different databses.

I can see 2 fixes for this. One is to simply make the connection_like module pub or at least the ToConnection trait.
The second solution would be to replace the above code with a simple reexport. I personally don't see why there need to be 2 different traits, but maybe I'm missing something.

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

No branches or pull requests

1 participant