fix: minor fixes to types

This commit is contained in:
2024-09-15 18:26:32 +02:00
parent 2c75b20349
commit 4d974d086f
2 changed files with 17 additions and 1 deletions

View File

@@ -20,8 +20,21 @@ func Unwrap_or_else[T any](val Unwrappable[T], f func() T) T {
return val.Unwrap_or_else(f)
}
// T cannot be inferred
// Returns if the underlying data has a Value (false in case of None or Error)
func Has_value(val ValueContainer) bool {
return val.Has_value()
}
func ResultWrap[T any](val T, err error) Result[T] {
if err == nil {
return Ok(val)
}
return Err[T](err)
}
func ResultWrapb[T any](err error, val T) Result[T] {
if err == nil {
return Ok(val)
}
return Err[T](err)
}