1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

//#![feature(extern_prelude)]
#![feature(generator_trait, generators)]
//! This crate is build for easy convertion from generators to iterators,
//! and for `chaining` generators in different kinds of ways.

/// A macro that first yields all items in the provided Generator, gives the ability to bind the return value of the Generator to a variable.
#[macro_export]
macro_rules! yield_from {

    ($g:expr) => (
        unsafe {
            loop {
                match $g.resume() {
                    GeneratorState::Yielded(y) => yield y,
                    GeneratorState::Complete(ret) => break ret,
                }
            }
        }
    );
}

#[cfg(feature = "futuresext")]
extern crate futures;

pub mod gen;
pub mod iter;


#[cfg(test)]
mod tests;