From d6cd0f1f2012e8817ac53a15871214b2a1a58446 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 4 Jan 2021 13:35:34 +0000 Subject: [PATCH] removed f variable, to fix --- rustybot/src/events.rs | 20 ++++++++++++-------- rustybot/src/positions.rs | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rustybot/src/events.rs b/rustybot/src/events.rs index ad66e63..ad7f0ee 100644 --- a/rustybot/src/events.rs +++ b/rustybot/src/events.rs @@ -119,11 +119,15 @@ impl EventDispatcher { F: Fn(&Event, &PairStatus) -> Fut, Fut: Future + Send, { - let f = Box::new(move |e, s| tokio::spawn(f(&e, s))); - match event { - EventKind::Any => self.on_any_event_handlers.push(f), - _ => self.event_handlers.entry(event).or_default().push(f), + EventKind::Any => self + .on_any_event_handlers + .push(Box::new(move |e, s| tokio::spawn(f(&e, s)))), + _ => self + .event_handlers + .entry(event) + .or_default() + .push(Box::new(move |e, s| tokio::spawn(f(&e, s)))), } } @@ -135,15 +139,15 @@ impl EventDispatcher { F: Fn(&PositionWrapper, &PairStatus) -> Fut, Fut: Future + Send, { - let f = Box::new(move |pw, s| tokio::spawn(f(&pw, s))); - match state { - PositionState::Any => self.on_any_position_state_handlers.push(f), + PositionState::Any => self + .on_any_position_state_handlers + .push(Box::new(move |pw, s| tokio::spawn(f(&pw, s)))), _ => self .position_state_handlers .entry(state) .or_default() - .push(f), + .push(Box::new(move |pw, s| tokio::spawn(f(&pw, s)))), } } } diff --git a/rustybot/src/positions.rs b/rustybot/src/positions.rs index f588cb5..313f961 100644 --- a/rustybot/src/positions.rs +++ b/rustybot/src/positions.rs @@ -13,6 +13,7 @@ pub enum PositionState { impl PositionState { fn color(self) -> String { match self { + PositionState::Any => "blue", PositionState::Critical | PositionState::Loss => "red", PositionState::BreakEven => "yellow", PositionState::MinimumProfit | PositionState::Profit => "green",