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
use TokenStream;
use parse_macro_input;
/// Implements [`TimeIntegrable`] for structs whose fields all implement it.
///
/// When applied to a struct, this macro:
///
/// - Generates a time derivative struct named `{StructName}TimeDerivative`,
/// where each field is a [`TimeDerivative<T>`] corresponding to the original field's type.
/// - Implements [`TimeIntegrable`] for the struct by calling `.step(...)` on each field,
/// using that field's own [`TimeIntegrable`] implementation.
///
/// ## Restrictions
///
/// - The input struct must use named fields (not tuple or unit structs).
/// - All fields must implement [`TimeIntegrable`].
///
/// ## Example
///
/// ### Input
///
/// ```ignore
/// #[derive(TimeIntegrable)]
/// struct StateVariables {
/// temperature: ThermodynamicTemperature,
/// pressure: Pressure,
/// }
/// ```
///
/// ### Expanded
///
/// ```ignore
/// #[derive(Debug, Clone, Copy, PartialEq)]
/// struct StateVariablesTimeDerivative {
/// temperature: TimeDerivative<ThermodynamicTemperature>,
/// pressure: TimeDerivative<Pressure>,
/// }
///
/// impl TimeIntegrable for StateVariables {
/// type Derivative = StateVariablesTimeDerivative;
///
/// fn step(self, derivative: Self::Derivative, dt: Time) -> Self {
/// Self {
/// temperature: self.temperature.step(derivative.temperature, dt),
/// pressure: self.pressure.step(derivative.pressure, dt),
/// }
/// }
/// }
/// ```
///
/// [`TimeIntegrable`]: twine_core::TimeIntegrable
/// [`TimeDerivative<T>`]: twine_core::TimeDerivative