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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/// This attribute defines a function-like macro based on the template module it
/// annotated. One can define actual modules with variations by calling the
/// defined macro with different arguments.
///
/// # Example
///
/// ```ignore
/// // To define a module-defining macro that called `define_foo_mod`, and let
/// // the macro user to customize some functions in the module by specifying
/// // ways to construct variables (`BAR`), substitute attributes (along with
/// // extend the function signature) (`BAZ`), one can write:
/// #[mod_template::define(
/// macro_rules! define_foo_mod;
/// constructions(BAR -> impl crate::BarTrait),
/// attribute_substitutions(BAZ)),
/// ]
/// mod __ {
/// #[__CONSTRUCT(bar as BAR)]
/// #[__SUBSTITUTE(BAZ)]
/// fn an_fn() {
/// bar.do_something();
/// }
/// }
///
/// // Call the defined macro to produce an actual module (named as `actual_foo`):
/// define_foo_mod! {
/// mod actual_foo;
/// constructions {
/// BAR => crate::Bar::new(),
/// },
/// attribute_substitutions {
/// BAZ => #[::baz::baz],
/// // If one want to extend the signature of the function annotated by
/// // `#[__SUBSTITUTE(BAZ)]`, use
/// // `BAZ => #[::baz::baz] (.., qux: crate::Qux),`.
/// },
/// }
/// ```
pub use define;
/// This attribute is used by the attribute `mod_template::define` internally.
/// One should not use this attribute manually.
pub use __monomorphize_mod;
/// Turns something like:
///
/// ```
/// #[mod_template::construct(one = 1, mut to_be_three: i32 = 2)]
/// #[test]
/// fn test_one_adds_three() {
/// to_be_three += 1;
/// assert_eq!(format!("{}", one + to_be_three), four_text.to_string())
/// }
/// ```
///
/// into:
///
/// ```no_run
/// #[test]
/// fn test_one_adds_three() {
/// let one = 1;
/// let mut to_be_three: i32 = 2;
/// let four_text = {
/// fn type_checked() -> impl std::fmt::Display { "4" }
/// type_checked()
/// };
/// to_be_three += 1;
/// assert_eq!(format!("{}", one + to_be_three), four_text.to_string())
/// }
/// ```
pub use construct;
/// Turns something like:
///
/// ```
/// #[mod_template::extend_parameter_list(.., mut input: i32, output: &mut i32)]
/// fn abs() {
/// input = input.abs();
/// *output = input;
/// }
/// ```
///
/// into:
///
/// ```no_run
/// fn abs(mut input: i32, output: &mut i32) {
/// input = input.abs();
/// *output = input;
/// }
/// ```
pub use extend_parameter_list;