Dispatcher::handle_message does not need Result anymore (#365)

* Dispatcher::handle_message does not need Result anymore (1)

Callers can get rid of result handling, too.

* Dispatcher::handle_message does not need Result anymore (2)

* Dispatcher::handle_message does not need Result anymore (3) cargo fmt
This commit is contained in:
phimuemue
2021-08-30 21:41:58 -07:00
committed by Keavon Chambers
parent 16a7877a23
commit 2ef9038667
4 changed files with 91 additions and 100 deletions
+5 -6
View File
@@ -39,12 +39,11 @@ impl Editor {
Self { dispatcher: Dispatcher::new() }
}
pub fn handle_message<T: Into<Message>>(&mut self, message: T) -> Result<Vec<FrontendMessage>, EditorError> {
self.dispatcher.handle_message(message).map(|_| {
let mut responses = Vec::new();
std::mem::swap(&mut responses, &mut self.dispatcher.responses);
responses
})
pub fn handle_message<T: Into<Message>>(&mut self, message: T) -> Vec<FrontendMessage> {
self.dispatcher.handle_message(message);
let mut responses = Vec::new();
std::mem::swap(&mut responses, &mut self.dispatcher.responses);
responses
}
}