1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
package x type Configure[T any] func(T) type Option[T any] func(T) T type Factory[T any] func() T func New[T any](options ...Option[T]) T { item := Default[T]() for _, option := range options { item = option(item) } return item } func With[T any](with Configure[T]) Option[T] { return func(item T) T { with(item) return item } }