Macro shades::lit[][src]

macro_rules! lit {
    ($e:expr) => { ... };
    ($a:expr, $b:expr) => { ... };
    ($a:expr, $b:expr, $c:expr) => { ... };
    ($a:expr, $b:expr, $c:expr, $d:expr) => { ... };
}

Create various forms of literal expressions.

This macro allows you to create literal expressions by lifting Rust constants into the EDSL. The way this is done is via several forms:

  • lit!(x) lifts a single Rust expression into the EDSL. It’s isomorphic to Expr::from(x).
  • lit!(x, y) lifts two Rust expressions into the EDSL as a 2D scalar vector. It’s isomorphic to Expr::from(V2::from([x, y])).
  • lit!(x, y, z) lifts three Rust expressions into the EDSL as a 3D scalar vector. It’s isomorphic to Expr::from(V3::from([x, y, z])).
  • lit!(x, y, z, w) lifts three Rust expressions into the EDSL as a 3D scalar vector. It’s isomorphic to Expr::from(V4::from([x, y, z, w])).

Most of the time, type inference will kick in and you shouldn’t have to annotate the return expression.

Examples

use shades::{lit};

let _ = lit!(1);
let _ = lit!(false);
let _ = lit!(1., 2., 3., 4.);