Open renom opened 7 months ago
Would it be enough to make MapItem
an interface
here?
Something like that:
type MapItem interface {
KeyToAny() interface{}
ValueToAny() interface{}
}
Then the generic MapSlice
implementation would be out of go-yaml
's scope.
E.g. the following code could be used in the app:
type MapSlice[K, V any] []MapItem[K, V]
type MapItem[K, V any] struct {
Key K
Value V
}
func (m MapItem[K, V]) KeyToAny() interface{} {
return m.Key
}
func (m MapItem[K, V]) ValueToAny() interface{} {
return m.Value
}
Or the latter code could be on the go-yaml
's side too.
Example: