macro_rules! args { (@ifn { $value:expr } $name:ident) => { ... }; (@ifn {} $name:ident) => { ... }; ($($name:ident $(: $value:expr)?),* $(,)?) => { ... }; }
Expand description
A convenience macro for constructing named arguments.
This macro uses the builder()
function of a
named arguments type, and can only be used in positions
where the type can be inferred by the compiler (i.e. as a function argument
or an assignment to a variable with an explicit type).
Examples
use binrw::BinRead;
#[derive(BinRead)]
#[br(import { a: i32, b: i32 })]
struct Foo;
let mut reader = Cursor::new(b"");
let a = 1;
Foo::read_args(&mut reader, binrw::args! {
a,
b: { a * 2 },
}).unwrap();