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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#![allow(clippy::used_underscore_binding, clippy::all, warnings, missing_docs)]
//! Purpose: Provides a manual implementation of constructors and `FormingEnd` for an enum
//! with unnamed (tuple) variants, including static methods and a standalone subformer starter,
//! to serve as a reference for verifying the `#[ derive( Former ) ]` macro's behavior.
//!
#![allow(dead_code)] // Test structures are intentionally unused
//! Coverage:
//! - Rule 3d (Tuple + Default -> Subform): Manual implementation of static method `FunctionStep::run()`.
//! - Rule 2d (Tuple + `#[ subform_scalar ]` -> InnerFormer): Manual implementation of static method `FunctionStep::r#break()`.
//! - Rule 4a (#[`standalone_constructors`]): Manual implementation of the standalone subformer starter `break_variant()`.
//! - Rule 4b (Option 2 Logic): Manual implementation of `FormingEnd` for the variant end types.
//!
//! Test Relevance/Acceptance Criteria:
//! - Defines an enum `FunctionStep` with two single-field tuple variants: `Break(Break)` and `Run(Run)`.
//! - Manually implements static methods (`FunctionStep::r#break()`, `FunctionStep::run()`) and a standalone
//! subformer starter (`break_variant()`) that mirror the expected generated code.
//! - Manually implements `FormingEnd` for the end types associated with the variant subformers.
//! - This file is included by `basic_only_test.rs` to provide the manual implementations that
//! the shared tests compare against.
use super::*;
use former::StoragePreform;
// --- Inner Struct Definitions ---
// Re-enabled Former derive - testing if trailing comma issue is fixed
#[ derive( Debug, Clone, PartialEq, former::Former ) ]
pub struct Break { pub condition: bool }
#[ derive( Debug, Clone, PartialEq, former::Former ) ]
pub struct Run { pub command: String }
// --- Enum Definition ---
#[ derive( Debug, Clone, PartialEq ) ]
pub enum FunctionStep
{
Break(Break),
Run(Run),
}
// --- Specialized End Structs ---
#[ derive( Default, Debug ) ] pub struct FunctionStepBreakEnd;
#[ derive( Default, Debug ) ] pub struct FunctionStepRunEnd;
// --- Static Variant Constructor Methods ---
impl FunctionStep
{
#[ inline( always ) ]
pub fn r#break() // Using raw identifier
-> BreakFormer< BreakFormerDefinition< (), Self, FunctionStepBreakEnd > >
{
// Correct: Call associated function `begin` on the Former type
BreakFormer::begin( None, None, FunctionStepBreakEnd )
}
#[ inline( always ) ]
pub fn run()
-> RunFormer< RunFormerDefinition< (), Self, FunctionStepRunEnd > >
{
// Correct: Call associated function `begin` on the Former type
RunFormer::begin( None, None, FunctionStepRunEnd )
}
// Standalone constructors for #[ standalone_constructors ] attribute
#[ inline( always ) ]
pub fn break_variant()
-> BreakFormer< BreakFormerDefinition< (), Self, FunctionStepBreakEnd > >
{
BreakFormer::begin( None, None, FunctionStepBreakEnd )
}
#[ inline( always ) ]
pub fn run_variant()
-> RunFormer< RunFormerDefinition< (), Self, FunctionStepRunEnd > >
{
RunFormer::begin( None, None, FunctionStepRunEnd )
}
}
// Note: break_variant is now implemented as a method on the enum above
// --- FormingEnd Implementations for End Structs ---
// End for Break variant
impl former::FormingEnd
<
BreakFormerDefinitionTypes< (), FunctionStep > // Context is (), Formed is FunctionStep
>
for FunctionStepBreakEnd
{
#[ inline( always ) ]
fn call
(
&self,
sub_storage : BreakFormerStorage, // Storage of the inner type (Break)
_context : Option< () >, // Context is () from ::begin
) -> FunctionStep // Returns the Enum type
{
let data = sub_storage.preform(); // Get the Break data
FunctionStep::Break( data ) // Construct the enum variant
}
}
// End for Run variant
impl former::FormingEnd
<
RunFormerDefinitionTypes< (), FunctionStep > // Context is (), Formed is FunctionStep
>
for FunctionStepRunEnd
{
#[ inline( always ) ]
fn call
(
&self,
sub_storage : RunFormerStorage, // Storage of the inner type (Run)
_context : Option< () >, // Context is () from ::begin
) -> FunctionStep // Returns the Enum type
{
let data = sub_storage.preform(); // Get the Run data
FunctionStep::Run( data ) // Construct the enum variant
}
}
// Include the test logic
include!( "basic_only_test.rs" ); // Renamed from _static_only_test