Enum ::std::ops::GeneratorState

Enum indicating the state of a generator.

Variants

Protocols

protocol partial_eq
if value == b { }

Test for partial equality over a generator state.

Examples

use std::ops::{Generator, GeneratorState};

fn generate() {
   let n = yield 1;
   yield 2 + n;
}

let g = generate();

assert_eq!(g.resume(()), GeneratorState::Yielded(1));
assert_eq!(g.resume(1), GeneratorState::Yielded(3));
assert_eq!(g.resume(()), GeneratorState::Complete(()));
``
protocol eq
if value == b { }

Test for total equality over a generator state.

Examples

use std::ops::{Generator, GeneratorState};
use std::ops::eq;

fn generate() {
   let n = yield 1;
   yield 2 + n;
}

let g = generate();

assert!(eq(g.resume(()), GeneratorState::Yielded(1)));
assert!(eq(g.resume(1), GeneratorState::Yielded(3)));
assert!(eq(g.resume(()), GeneratorState::Complete(())));
``