Limit the scope of borrow_mut in consume_queue

Otherwise we may accidentally hold the borrowed ref cell for too long which can
cause a borrow error.

Closes #190
This commit is contained in:
Alex Crichton
2017-03-15 22:59:08 -07:00
parent 8383e8bf7a
commit 37e2870f04
2 changed files with 23 additions and 3 deletions
+2 -1
View File
@@ -411,7 +411,8 @@ impl Core {
// TODO: can we do better than `.unwrap()` here?
let unpark = self.rx_readiness.clone();
loop {
match self.rx.borrow_mut().poll_stream(unpark.clone()).unwrap() {
let msg = self.rx.borrow_mut().poll_stream(unpark.clone()).unwrap();
match msg {
Async::Ready(Some(msg)) => self.notify(msg),
Async::NotReady |
Async::Ready(None) => break,