Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
24
third-party/vendor/generator/examples/get_yield.rs
vendored
Normal file
24
third-party/vendor/generator/examples/get_yield.rs
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#![allow(deprecated)]
|
||||
use generator::{get_yield, yield_with, Gn};
|
||||
|
||||
fn sum(a: u32) -> u32 {
|
||||
let mut sum = a;
|
||||
let mut recv: u32;
|
||||
while sum < 200 {
|
||||
recv = get_yield().unwrap();
|
||||
yield_with(sum);
|
||||
sum += recv;
|
||||
}
|
||||
|
||||
sum
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// we specify the send type is u32
|
||||
let mut s = Gn::<u32>::new(|| sum(1));
|
||||
let mut i = 1u32;
|
||||
while !s.is_done() {
|
||||
i = s.send(i);
|
||||
println!("{i}");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue