This commit is contained in:
Ivar Fatland
2025-09-15 21:24:51 +02:00
parent 56f361a435
commit cecafee61c
3 changed files with 86 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
package dimcli
type Optional[T any] struct {
isSome bool
value T
}
func Some[T any](value T) Optional[T] {
return Optional[T]{
isSome: true,
value: value,
}
}
func None[T any]() Optional[T] {
return Optional[T]{
isSome: false,
}
}
func (o *Optional[T]) Get() (T, bool) {
return o.value, o.isSome
}