auto merge of #10688 : bjz/rust/recv_iter, r=brson
I've noticed I use this pattern quite a bit: ~~~rust do spawn { loop { match port.try_recv() { Some(x) => ..., None => ..., } } } ~~~ The `RecvIterator`, returned from a default `recv_iter` method on the `GenericPort` trait, allows you to reduce this down to: ~~~rust do spawn { for x in port.recv_iter() { ... } } ~~~ As demonstrated in the tests, you can also access the port from within the `for` block for further `recv`ing and `peek`ing with no borrow errors, which is quite nice.
Showing
想要评论请 注册 或 登录