mirror of https://github.com/rwf2/Rocket.git
Implement 'DerefMut' for database pools.
This commit also fixes database pool codegen amidst of generics. Fixes #854. Resolves #862.
This commit is contained in:
parent
9750ae67dd
commit
7dd0c8fd02
|
@ -91,7 +91,7 @@ pub fn database_attr(attr: TokenStream, input: TokenStream) -> Result<TokenStrea
|
||||||
|
|
||||||
::rocket::fairing::AdHoc::on_attach(#fairing_name, |rocket| {
|
::rocket::fairing::AdHoc::on_attach(#fairing_name, |rocket| {
|
||||||
let pool = #databases::database_config(#name, rocket.config())
|
let pool = #databases::database_config(#name, rocket.config())
|
||||||
.map(#connection_type::pool);
|
.map(<#connection_type>::pool);
|
||||||
|
|
||||||
match pool {
|
match pool {
|
||||||
Ok(Ok(p)) => Ok(rocket.manage(#pool_type(p))),
|
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 {
|
impl<'a, 'r> #request::FromRequest<'a, 'r> for #request_guard_type {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue