Make connection_like::ToConnection public
Wasabi375 opened this issue · 0 comments
Wasabi375 commented
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.