1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use optargs_macro;
/// Optional arguments for functions!
/// Add optfn on top of any function and then you can call the funtion with optional arguments.
///
/// Note that this still obeys traditional macro_rules, so you can only use the macro *after* declaration or import it from "crate".
///
///
/// ```ignore
/// #[optargs::optfn]
/// pub fn plot(
/// x: Vec<i32>,
/// y: Option<Vec<i32>>,
/// title: Option<&str>,
/// xlabel: Option<&str>,
/// ylabel: Option<&str>,
/// legend: Option<bool>
/// ) {}
///
/// // can now call it with optional arguments
/// plot!(
/// x: vec![1,2,3],
/// y: vec![1,2,3],
/// title: "Awesome plot",
/// xlabel: "x axis",
/// ylabel: "y axis"
/// );
/// ```
pub use optfn;
/// Flexible struct builder with optional arguments
/// Derive OptStruct for your structs and then call the Struct's name as a macro to build it, eliding optionals.
///
/// Note that this still obeys traditional macro_rules, so you can only use the macro *after* declaration or import it from "crate".
///
/// ```rust
/// #[derive(optargs::OptStruct)]
/// pub struct Scatter {
/// x: Vec<i32>,
/// y: Option<Vec<i32>>,
/// title: Option<&str>,
/// xlabel: Option<&str>,
/// ylabel: Option<&str>,
/// legend: Option<bool>
/// }
///
/// let plot = Scatter!{
/// x: vec![1,2,3],
/// legend: true
/// };
/// ```
pub use OptStruct;