mirror of https://github.com/rwf2/Rocket.git
Clean up 'AdHoc' fairing implementation.
This commit is contained in:
parent
7c2dda2647
commit
fdd76ecf7e
|
@ -144,10 +144,8 @@ impl Fairing for AdHoc {
|
||||||
|
|
||||||
fn on_attach(&self, rocket: Rocket) -> Result<Rocket, Rocket> {
|
fn on_attach(&self, rocket: Rocket) -> Result<Rocket, Rocket> {
|
||||||
if let AdHocKind::Attach(ref mutex) = self.kind {
|
if let AdHocKind::Attach(ref mutex) = self.kind {
|
||||||
let mut option = mutex.lock().expect("AdHoc::Attach lock");
|
let mut opt = mutex.lock().expect("AdHoc::Attach lock");
|
||||||
let f = option
|
let f = opt.take().expect("internal error: `on_attach` one-call invariant broken");
|
||||||
.take()
|
|
||||||
.expect("internal error: `on_attach` single-call invariant broken");
|
|
||||||
f(rocket)
|
f(rocket)
|
||||||
} else {
|
} else {
|
||||||
Ok(rocket)
|
Ok(rocket)
|
||||||
|
@ -156,10 +154,8 @@ impl Fairing for AdHoc {
|
||||||
|
|
||||||
fn on_launch(&self, rocket: &Rocket) {
|
fn on_launch(&self, rocket: &Rocket) {
|
||||||
if let AdHocKind::Launch(ref mutex) = self.kind {
|
if let AdHocKind::Launch(ref mutex) = self.kind {
|
||||||
let mut option = mutex.lock().expect("AdHoc::Launch lock");
|
let mut opt = mutex.lock().expect("AdHoc::Launch lock");
|
||||||
let f = option
|
let f = opt.take().expect("internal error: `on_launch` one-call invariant broken");
|
||||||
.take()
|
|
||||||
.expect("internal error: `on_launch` single-call invariant broken");
|
|
||||||
f(rocket)
|
f(rocket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue