diff options
| author | bors <bors@rust-lang.org> | 2013-11-27 01:52:10 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-27 01:52:10 -0800 |
| commit | 17af6f7d0c92ee66df6b96d088e999db378ce125 (patch) | |
| tree | 65f40f7d033969cd37a071f5242685f4305a684e /src/rustllvm/RustWrapper.cpp | |
| parent | faf4c939fb6c55f0b9d19b1292fa4601169b3c17 (diff) | |
| parent | 31da6b76986f337483a971884113a043c835102b (diff) | |
| download | rust-17af6f7d0c92ee66df6b96d088e999db378ce125.tar.gz rust-17af6f7d0c92ee66df6b96d088e999db378ce125.zip | |
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.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
