Add convenience constructor for Option
This commit is contained in:
parent
c5e2e0f993
commit
b514c0d621
@ -6,6 +6,10 @@ import "git.tebibyte.media/sashakoshka/go-util/container"
|
|||||||
// TODO make generic alias once go 1.24 releases
|
// TODO make generic alias once go 1.24 releases
|
||||||
type Option[T any] ucontainer.Optional[T]
|
type Option[T any] ucontainer.Optional[T]
|
||||||
|
|
||||||
|
func O[T any](value T) Option[T] {
|
||||||
|
return Option[T](ucontainer.O(value))
|
||||||
|
}
|
||||||
|
|
||||||
func (option *Option[T]) Get() (T, bool) {
|
func (option *Option[T]) Get() (T, bool) {
|
||||||
return option.Get()
|
return option.Get()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user