inital commit

This commit is contained in:
2024-09-12 22:16:26 +02:00
commit 2c75b20349
14 changed files with 653 additions and 0 deletions

27
typeutils/utils.go Normal file
View File

@@ -0,0 +1,27 @@
package typeutils
func Expect[T any](val Unwrappable[T], msg string) T {
return val.Expect(msg)
}
func Unwrap[T any](val Unwrappable[T]) T {
return val.Unwrap()
}
func Unwrap_or[T any](val Unwrappable[T]) (def T) {
return val.Unwrap_or(def)
}
func Unwrap_or_default[T any](val Unwrappable[T]) T {
return val.Unwrap_or_default()
}
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()
}