Implement 'DerefMut' for database pools.

This commit also fixes database pool codegen amidst of generics.

Fixes #854.
Resolves #862.
This commit is contained in:
Eric Dattore 2018-12-11 13:57:23 -08:00 committed by Sergio Benitez
parent 9750ae67dd
commit 7dd0c8fd02
1 changed files with 8 additions and 1 deletions

View File

@ -91,7 +91,7 @@ pub fn database_attr(attr: TokenStream, input: TokenStream) -> Result<TokenStrea
::rocket::fairing::AdHoc::on_attach(#fairing_name, |rocket| {
let pool = #databases::database_config(#name, rocket.config())
.map(#connection_type::pool);
.map(<#connection_type>::pool);
match pool {
Ok(Ok(p)) => Ok(rocket.manage(#pool_type(p))),
@ -130,6 +130,13 @@ pub fn database_attr(attr: TokenStream, input: TokenStream) -> Result<TokenStrea
}
}
impl ::std::ops::DerefMut for #request_guard_type {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<'a, 'r> #request::FromRequest<'a, 'r> for #request_guard_type {
type Error = ();