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
//! Comprehensive tests for `VariadicFrom` derive macro.
//!
//! Tests all corner cases for the `#[derive(VariadicFrom)]` macro including:
//! - Single-field tuple structs (auto `variadic_from`)
//! - Single-field named structs (auto `variadic_from`)
//! - Generic types
//!
//! ## Test Matrix
//!
//! | Test Case | Type | Fields | Expected | Status |
//! |-----------|------|--------|----------|--------|
//! | `test_single_field_tuple` | Struct Tuple | 1 | Success | ✅ |
//! | `test_single_field_named` | Struct Named | 1 | Success | ✅ |
//! | `test_generic_single_field` | Struct Tuple | 1 generic | Success | ✅ |
//!
//! **Semantics:**
//! The `VariadicFrom` derive implements an inherent `variadic_from()` method that constructs
//! the struct from its inner field type. Similar to `From` but uses a different method name.
//!
//! **Known Limitation:**
//! Enum support is NOT functional with inherent method approach. Enums with multiple variants
//! would generate duplicate method names (one per variant), which Rust rejects. Enum support
//! requires trait-based implementation, which needs `VariadicFrom` trait definition to exist.
//!
//! ## Root Cause (Issue #4 - FIXED for structs)
//!
//! Original implementation generated `impl crate::VariadicFrom<T>` for non-existent trait,
//! causing compile errors. All derive usage failed with "expected trait, found derive macro".
//!
//! ## Why Not Caught
//!
//! No comprehensive test coverage for `VariadicFrom` derive existed in `derive_tools_meta`.
//! Parent crate tests may have been disabled or not comprehensive.
//!
//! ## Fix Applied
//!
//! Changed implementation from trait impl to inherent method (`src/derive/variadic_from.rs:107`, `208`).
//! Now generates `impl MyStruct { pub fn variadic_from(...) -> Self }` instead of
//! `impl crate::VariadicFrom<T> for MyStruct`.
//!
//! ## Prevention
//!
//! Added comprehensive test suite with 3 test cases covering tuple/named structs and generics.
//! Test file documents semantics, validates inherent method behavior, and documents enum limitation.
//!
//! ## Pitfall
//!
//! Variadic conversion patterns require custom traits. Must define trait before implementing it,
//! or use inherent methods for utility constructors. Inherent methods cannot support enums with
//! multiple variants (duplicate method names).
use *;
/// Test 1: Single-field tuple struct
///
/// Should generate inherent `variadic_from()` method for the inner field type.
/// Test 2: Single-field named struct
///
/// Should generate inherent `variadic_from()` method for the single field type.
/// Test 3: Generic single-field struct
///
/// Should work with generic type parameters.