Function rf_core::lang::branch

source ·
pub fn branch<A: Clone + 'static + FromStr, B, TH, EL>(
    vm: RoundVM,
    cond: B,
    thn: TH,
    els: EL
) -> (RoundVM, A)
where B: Fn() -> bool, TH: Fn(RoundVM) -> (RoundVM, A), EL: Fn(RoundVM) -> (RoundVM, A),
Expand description

Partitions the domain into two subspaces that do not interact with each other.

Arguments

  • vm the current VM
  • cond the condition to evaluate
  • thn the expression to evaluate if the condition is true
  • els the expression to evaluate if the condition is false

Generic Parameters

  • A The type of value returned by the expression.
  • B - The type of cond, which must be a closure that takes no arguments and returns a value of type bool.
  • F - The type of thn and els, which must be a closure that takes a RoundVM as argument and returns a tuple (RoundVM, A).

Returns

the value of the expression