Macro equation

Source
macro_rules! equation {
    (|| $expr:expr) => { ... };
    (|$t:ident| $expr:expr) => { ... };
    (|[$($x:pat),+]| $expr:expr) => { ... };
    (|$t:pat, [$($x:pat),+]| $expr:expr) => { ... };
    (|$t:pat, [$($x:pat),+], [$($x_:pat),+]| $expr:expr) => { ... };
}
Expand description

Creates a crate::Equation from a closure.

equation! allows Equation to be defined with closures of different calling signatures, being like an overloading version of constructors of crate::Equation:

use diffurch::equation;
let constant = equation!(|| [1.]);
let time = equation!(|t| [t.sin(), t.cos()]);
let ode = equation!(|[x, y]| [-y, x]);
let ode2 = equation!(|t, [x, y]| [-y / t, x * t]);
let dde = equation!(|t, [x], [x_]| [4. * x * (1. - x_(t - 1.))]);
let ndde = equation!(|t, [x], [x_]| [4. * x * (1. - x_.d(t - 1.))]);