Enum std::ops::ControlFlow

Overview

Used to tell an operation whether it should exit early or go on as usual.

This acts as the basis of the TRY protocol in Rune.

Examples

use std::ops::ControlFlow;

let c = ControlFlow::Continue(42);
assert_eq!(c.0, 42);
assert_eq!(c, ControlFlow::Continue(42));

Trait Implementations

impl PartialEq for ControlFlow
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 ControlFlow
impl Clone for ControlFlow
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 two control flows for partial equality.

Examples

use std::ops::{partial_eq, ControlFlow};

assert_eq! {
   partial_eq(ControlFlow::Continue(true), ControlFlow::Continue(true)),
   true
};
assert_eq! {
   partial_eq(ControlFlow::Continue(true), ControlFlow::Break(false)),
   false
};
assert_eq! {
   partial_eq(ControlFlow::Break(false), ControlFlow::Continue(true)),
   false
};
protocol EQ
if value == b { }

Test two control flows for total equality.

Examples

use std::ops::{eq, ControlFlow};

assert_eq! {
   eq(ControlFlow::Continue(true), ControlFlow::Continue(true)),
   true
};
assert_eq! {
   eq(ControlFlow::Continue(true), ControlFlow::Break(false)),
   false
};
assert_eq! {
   eq(ControlFlow::Break(false), ControlFlow::Continue(true)),
   false
};
protocol DEBUG_FMT
format!("{:?}", value)

Debug print the control flow.

Examples

use std::ops::ControlFlow;

let string = format!("{:?}", ControlFlow::Continue(true));
protocol CLONE
let $out = clone(value)

Clone the control flow.

Examples

use std::ops::ControlFlow;

let flow = ControlFlow::Continue("Hello World");
let flow2 = flow.clone();

assert_eq!(flow, flow2);