core\iter\sources/generator.rs
1/// Creates a new closure that returns an iterator where each iteration steps the given
2/// generator to the next `yield` statement.
3///
4/// Similar to [`iter::from_fn`], but allows arbitrary control flow.
5///
6/// [`iter::from_fn`]: crate::iter::from_fn
7///
8/// # Examples
9///
10/// ```
11/// #![feature(iter_macro, coroutines)]
12/// # #[cfg(not(bootstrap))]
13/// # {
14///
15/// let it = std::iter::iter!{|| {
16/// yield 1;
17/// yield 2;
18/// yield 3;
19/// } }();
20/// let v: Vec<_> = it.collect();
21/// assert_eq!(v, [1, 2, 3]);
22/// # }
23/// ```
24#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")]
25#[allow_internal_unstable(coroutines, iter_from_coroutine)]
26#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
27pub macro iter($($t:tt)*) {
28 /* compiler-builtin */
29}