Commit 104cf06
authored
Refactor pointer utilities with generic implementations (#95)
* Refactor pointer utilities with generics
Replace type-specific pointer helper functions with generic Pointer[T]
and Dereference[T] implementations that work with any type.
Changes:
- Add generic Pointer[T any](val T) *T function to create pointers
- Add generic Dereference[T any](ptr *T) T function to safely dereference
- Deprecate type-specific functions: BoolP, PBool, StringP, PString,
IntP, PInt, Int32P, PInt32, Int64P, PInt64
- Add comprehensive unit tests with 100% coverage for generic functions
- Test coverage includes primitives, structs, nil handling, and zero values
Signed-off-by: AdityaHarindar <aditya.harindar@gmail.com>
* add test for structs with nested references
Signed-off-by: AdityaHarindar <aditya.harindar@gmail.com>
* simplify variable names
Signed-off-by: AdityaHarindar <aditya.harindar@gmail.com>
* replace deprecated BoolP() with Pointer()
Signed-off-by: AdityaHarindar <aditya.harindar@gmail.com>
---------
Signed-off-by: AdityaHarindar <aditya.harindar@gmail.com>1 parent 05e3844 commit 104cf06
3 files changed
Lines changed: 328 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
| 475 | + | |
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
6 | 28 | | |
7 | 29 | | |
8 | 30 | | |
| |||
11 | 33 | | |
12 | 34 | | |
13 | 35 | | |
| 36 | + | |
14 | 37 | | |
15 | 38 | | |
16 | 39 | | |
| |||
23 | 46 | | |
24 | 47 | | |
25 | 48 | | |
| 49 | + | |
26 | 50 | | |
27 | 51 | | |
28 | 52 | | |
| |||
31 | 55 | | |
32 | 56 | | |
33 | 57 | | |
| 58 | + | |
34 | 59 | | |
35 | 60 | | |
36 | 61 | | |
| |||
43 | 68 | | |
44 | 69 | | |
45 | 70 | | |
| 71 | + | |
46 | 72 | | |
47 | 73 | | |
48 | 74 | | |
| |||
51 | 77 | | |
52 | 78 | | |
53 | 79 | | |
| 80 | + | |
54 | 81 | | |
55 | 82 | | |
56 | 83 | | |
| |||
63 | 90 | | |
64 | 91 | | |
65 | 92 | | |
| 93 | + | |
66 | 94 | | |
67 | 95 | | |
68 | 96 | | |
| |||
71 | 99 | | |
72 | 100 | | |
73 | 101 | | |
| 102 | + | |
74 | 103 | | |
75 | 104 | | |
76 | 105 | | |
| |||
83 | 112 | | |
84 | 113 | | |
85 | 114 | | |
| 115 | + | |
86 | 116 | | |
87 | 117 | | |
88 | 118 | | |
| |||
91 | 121 | | |
92 | 122 | | |
93 | 123 | | |
| 124 | + | |
94 | 125 | | |
95 | 126 | | |
96 | 127 | | |
| |||
0 commit comments