Add option type
TODO: when go 1.24 drops, turn it into a generic type alias
This commit is contained in:
parent
3b97aa6a81
commit
9c64274622
13
option.go
13
option.go
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user