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
//! Purpose: This file is a test case demonstrating the current limitation and compilation failure
//! when attempting to use the `#[ subform_entry ]` attribute on a field that is a collection of enums
//! (specifically, `Vec<SimpleEnum>`). It highlights a scenario that is not currently supported by
//! the `Former` macro.
//!
//! Coverage:
//! - This file primarily demonstrates a scenario *not* covered by the defined "Expected Enum Former Behavior Rules"
//! because the interaction of `#[ subform_entry ]` with collections of enums is not a supported feature.
//! It implicitly relates to the concept of subform collection handling but serves as a test for an unsupported case.
//!
//! Test Relevance/Acceptance Criteria:
//! - Defines a simple enum `SimpleEnum` deriving `Former`.
//! - Defines a struct `StructWithEnumVec` containing a `Vec<SimpleEnum>` field.
//! - Applies `#[ subform_entry ]` to the `Vec<SimpleEnum>` field.
//! - The entire file content is commented out, including a test function (`attempt_subform_enum_vec`) that demonstrates the intended (but unsupported) usage of a hypothetical subformer for the enum collection.
//! - This file is intended to be a compile-fail test or a placeholder for a future supported feature. The test is accepted if attempting to compile code that uses `#[ subform_entry ]` on a collection of enums results in a compilation error (as indicated by the comments).
// // File: module/core/former/tests/inc/former_enum_tests/subform_collection_test.rs
// //! Minimal test case demonstrating the compilation failure
// //! when using `#[ subform_entry ]` on a `Vec<Enum>`.
// //
// // use super::*;
// // use former::Former;
// // use std::vec::Vec;
// //
// // /// A simple enum deriving Former.
// // #[ derive( Debug, PartialEq, Clone, Former ) ]
// // pub enum SimpleEnum
// // {
// // /// Unit variant.
// // Unit,
// // /// Tuple variant with a single value.
// // #[ scalar ] // Use scalar for direct constructor
// // Value( i32 ),
// // }
// //
// // /// A struct containing a vector of the enum.
// // #[ derive( Debug, PartialEq, Default, Former ) ]
// // pub struct StructWithEnumVec
// // {
// // /// Field attempting to use subform_entry on Vec<Enum>.
// // #[ subform_entry ]
// // items : Vec< SimpleEnum >,
// // }
// //
// // /// Test attempting to use the subformer generated for `items`.
// // /// This test FAIL TO COMPILE because `former` does not
// // /// currently support generating the necessary subformer logic for enum entries
// // /// within a collection via `#[ subform_entry ]`.
// // #[ test ]
// // fn attempt_subform_enum_vec()
// // {
// // // This code block demonstrates the intended usage that fails.
// // /*
// // let _result = StructWithEnumVec::former()
// // // Trying to access the subformer for the Vec<SimpleEnum> field.
// // // The derive macro does not generate the `.items()` method correctly
// // // for Vec<Enum> with #[ subform_entry ]. It doesn't know how to
// // // return a former that can then construct *specific enum variants*.
// // .items()
// // // Attempting to call a variant constructor method (e.g., .value())
// // // on the hypothetical subformer returned by .items(). This method
// // // would not be generated.
// // .value( 10 )
// // // Ending the hypothetical subformer for the first enum entry.
// // .end()
// // // Attempting to start another entry.
// // .items()
// // // Attempting to call the unit variant constructor method.
// // .unit()
// // // Ending the hypothetical subformer for the second enum entry.
// // .end()
// // // Finalizing the parent struct.
// // .form();
// // */
// //
// // // Assertion to make the test function valid, though it won't be reached
// // // if the compilation fails as expected.
// // assert!( true, "Test executed - compilation should have failed before this point." );
// // }
// // // qqq : xxx : make it working