Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
26
third-party/vendor/generator/examples/yield_from.rs
vendored
Normal file
26
third-party/vendor/generator/examples/yield_from.rs
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#![allow(deprecated)]
|
||||
|
||||
use generator::*;
|
||||
|
||||
fn xrange(start: u32, end: u32) -> u32 {
|
||||
for i in start..end {
|
||||
yield_with(i);
|
||||
}
|
||||
done!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let g1 = Gn::new(|| xrange(0, 10));
|
||||
let g2 = Gn::new(|| xrange(10, 20));
|
||||
|
||||
let g = Gn::new_scoped(|mut s| {
|
||||
s.yield_from(g1);
|
||||
s.yield_from(g2);
|
||||
done!();
|
||||
});
|
||||
|
||||
g.fold(0, |sum, x| {
|
||||
println!("i={}, sum={}", x, sum + x);
|
||||
sum + x
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue