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
# Task 011: Argument for Constructor Attribute
## ๐ **Overview**
Introduce field attribute `arg_for_constructor` to mark fields as arguments for constructing functions.
## ๐ฏ **Objectives**
- Add `arg_for_constructor` field attribute
- Mark fields that should be used in constructing functions
- Support both standalone constructors and associated constructors
- Handle enum field restrictions properly
- By default `arg_for_constructor` is false
## ๐ง **Technical Details**
### Field Marking
- Mark fields with `arg_for_constructor` attribute
- Fields marked as constructor arguments
- Works with both structs and enums
### Enum Restrictions
- `arg_for_constructor` attachable only to fields of variant
- **Error**: Attempting to attach to variant itself must throw understandable error
- Only variant fields can be constructor arguments
### Constructor Naming
- **Struct**: snake_case version of struct name
- **Enum**: snake_case version of variant name
### Default Behavior
- `arg_for_constructor` defaults to `false`
- Only marked fields become constructor arguments
## ๐ **Source Location**
File: `/home/user1/pro/lib/wTools/module/core/component_model/src/lib.rs`
Line: 12
## ๐ท๏ธ **Labels**
- **Type**: Feature Enhancement
- **Priority**: Medium
- **Difficulty**: ๐ก Medium
- **Value**: ๐ Medium
- **Status**: ๐ Planned
## ๐ฆ **Dependencies**
- Task 010: Standalone Constructors
- Component model core functionality
## ๐งช **Acceptance Criteria**
- [ ] Add `arg_for_constructor` field attribute parsing
- [ ] Support constructor arguments for struct fields
- [ ] Support constructor arguments for enum variant fields
- [ ] Validate enum usage (fields only, not variants)
- [ ] Generate constructors with proper arguments
- [ ] Provide clear error messages for invalid usage
- [ ] Add comprehensive tests
- [ ] Update documentation with examples