#underscore #syntax #named #arguments

nightly underscore_args

Macro for underscore named argument syntax, aka Dyon

3 releases

0.1.2 Dec 13, 2018
0.1.1 Dec 11, 2018
0.1.0 Dec 11, 2018

#2384 in Rust patterns

37 downloads per month

MIT license

5KB

underscore_args

Macro for underscore named argumet syntax, aka Dyon.

This library requires Rust 2018 nightly and only works for functions, not methods.

By naming a function line__color_from_to, one can call it like this:

args!(line(color: [1.0; 4], from: [0.0, 0.0], to: [100.0, 100.0]))
  • Double underscore after function name and before the name of the first argument
  • Single underscore separating arguments

Example

#![feature(concat_idents)]

use underscore_args::args;

#[allow(non_snake_case)]
fn line__color_from_to(_color: [f32; 4], _from: [f32; 2], _to: [f32; 2]) {}

args!(line(color: [1.0; 4], from: [0.0, 0.0], to: [100.0, 100.0]));

lib.rs:

Macro for underscore named argumet syntax, aka Dyon.

This library requires Rust 2018 nightly and only works for functions, not methods.

By naming a function line__color_from_to, one can call it like this:

args!(line(color: [1.0; 4], from: [0.0, 0.0], to: [100.0, 100.0]))
  • Double underscore after function name and before the name of the first argument
  • Single underscore separating arguments

Example

#![feature(concat_idents)]

use underscore_args::args;

#[allow(non_snake_case)]
fn line__color_from_to(_color: [f32; 4], _from: [f32; 2], _to: [f32; 2]) {}

args!(line(color: [1.0; 4], from: [0.0, 0.0], to: [100.0, 100.0]));

No runtime deps