Add option type

TODO: when go 1.24 drops, turn it into a generic type alias
This commit is contained in:
Sasha Koshka 2025-01-21 16:20:40 -05:00
parent 3b97aa6a81
commit 9c64274622

View File

@ -2,5 +2,18 @@ package hopp
import "git.tebibyte.media/sashakoshka/go-util/container"
// Option allows an optional value to be defined without using a pointer.
// TODO make generic alias once go 1.24 releases
type Option[T any] ucontainer.Optional[T]
func (option *Option[T]) Get() (T, bool) {
return option.Get()
}
func (option *Option[T]) Set(value T) {
option.Set(value)
}
func (option *Option[T]) Reset() {
option.Reset()
}