@@ -22,17 +22,17 @@ import (
22
22
type (
23
23
optionsReference [
24
24
OS optionSlice [OT , T ],
25
- OT optionFunc [T ],
25
+ OT generic. OptionFunc [T ],
26
26
T any ,
27
27
] interface {
28
28
* OS
29
29
}
30
- optionSlice [OT optionFunc [T ], T any ] interface {
30
+ optionSlice [
31
+ OT generic.OptionFunc [T ],
32
+ T any ,
33
+ ] interface {
31
34
~ []OT
32
35
}
33
- optionFunc [T any ] interface {
34
- ~ func (* T ) error
35
- }
36
36
sharedSettings struct {
37
37
verbose bool
38
38
}
@@ -82,18 +82,9 @@ const (
82
82
permSymText = 't'
83
83
)
84
84
85
- func makeWithOptions [OT optionFunc [T ], T any ](options ... OT ) (T , error ) {
85
+ func makeWithOptions [OT generic. OptionFunc [T ], T any ](options ... OT ) (T , error ) {
86
86
var settings T
87
- return settings , applyOptions (& settings , options ... )
88
- }
89
-
90
- func applyOptions [OT optionFunc [T ], T any ](settings * T , options ... OT ) error {
91
- for _ , apply := range options {
92
- if err := apply (settings ); err != nil {
93
- return err
94
- }
95
- }
96
- return nil
87
+ return settings , generic .ApplyOptions (& settings , options ... )
97
88
}
98
89
99
90
func (so * sharedOptions ) BindFlags (flagSet * flag.FlagSet ) {
@@ -519,7 +510,7 @@ func underline(text string) string {
519
510
func flagSetFunc [
520
511
OSR optionsReference [OS , OT , ST ],
521
512
OS optionSlice [OT , ST ],
522
- OT optionFunc [ST ],
513
+ OT generic. OptionFunc [ST ],
523
514
setterFn func (VT , * ST ) error ,
524
515
ST , VT any ,
525
516
](flagSet * flag.FlagSet , name , usage string ,
@@ -545,7 +536,7 @@ func funcFlag[T any](flagSet *flag.FlagSet, name, usage string, fn func(string)
545
536
func parseAndSet [
546
537
OSR optionsReference [OS , OT , ST ],
547
538
OS optionSlice [OT , ST ],
548
- OT optionFunc [ST ],
539
+ OT generic. OptionFunc [ST ],
549
540
setterFn func (VT , * ST ) error ,
550
541
ST , VT any ,
551
542
](parameter string , options OSR , setter setterFn ,
0 commit comments