Enum std::ops::generator::GeneratorState

Overview

Enum indicating the state of a generator.

Trait Implementations

impl PartialEq for GeneratorState
fn eq(value: any, value1: any) -> bool

Compare two values for equality.

Examples

assert_eq!(1.eq(2), false);
assert_eq!(2.eq(2), true);
assert_eq!(2.eq(1), false);
fn ne(value: any, value1: any) -> bool

Compare two values for inequality.

Examples

assert_eq!(1.ne(2), true);
assert_eq!(2.ne(2), false);
assert_eq!(2.ne(1), true);
impl Eq for GeneratorState
impl Clone for GeneratorState
fn clone(value: any) -> any

Clone the specified value.

Examples

let a = 42;
let b = a;
let c = a.clone();

a += 1;

assert_eq!(a, 43);
assert_eq!(b, 42);
assert_eq!(c, 42);

Protocols

protocol IS_VARIANT

Test if the provided argument is a variant.

protocol GET
let $out = value.0

Allows a get operation to work.

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(())));
``
protocol DEBUG_FMT
format!("{:?}", value)

Debug print this generator state.

Examples

use std::ops::GeneratorState;

let a = GeneratorState::Yielded(1);
let b = GeneratorState::Complete(());

println!("{a:?}");
println!("{b:?}");
``
protocol CLONE
let $out = clone(value)

Clone a generator state.

Examples

use std::ops::GeneratorState;

let a = GeneratorState::Yielded(1);
let b = a.clone();

assert_eq!(a, b);
``