@@ -15,10 +15,10 @@ func Err_t[T any](err error, x T) Result[T] {
|
||||
|
||||
// CTORS END
|
||||
|
||||
func (res Result[T]) Is_ok() bool { return res.err == nil }
|
||||
func (res Result[T]) Is_err() bool { return res.err != nil }
|
||||
func (res Result[T]) IsOk() bool { return res.err == nil }
|
||||
func (res Result[T]) IsErr() bool { return res.err != nil }
|
||||
|
||||
func (res Result[T]) Has_value() bool { return res.Is_ok() }
|
||||
func (res Result[T]) HasValue() bool { return res.IsOk() }
|
||||
|
||||
// UNWRAPPABLE INTERFACE
|
||||
func (res Result[T]) Expect(msg string) T {
|
||||
@@ -35,14 +35,14 @@ func (res Result[T]) Unwrap() T {
|
||||
panic("Tried unwrapping a Result that had an error value!")
|
||||
}
|
||||
|
||||
func (res Result[T]) Unwrap_or(val T) T {
|
||||
func (res Result[T]) UnwrapOr(val T) T {
|
||||
if res.err == nil {
|
||||
return res.value
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func (res Result[T]) Unwrap_or_default() T {
|
||||
func (res Result[T]) UnwrapOrDefault() T {
|
||||
if res.err == nil {
|
||||
return res.value
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (res Result[T]) Unwrap_or_default() T {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (res Result[T]) Unwrap_or_else(f func() T) T {
|
||||
func (res Result[T]) UnwrapOrElse(f func() T) T {
|
||||
if res.err == nil {
|
||||
return res.value
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (res Result[T]) Unwrap_or_else(f func() T) T {
|
||||
// UNWRAPPABLE INTERFACE
|
||||
|
||||
// This function panic on Ok instead of Err
|
||||
func (res Result[T]) Expect_err(msg string) error {
|
||||
func (res Result[T]) ExpectErr(msg string) error {
|
||||
if res.err != nil {
|
||||
return res.err
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (res Result[T]) Expect_err(msg string) error {
|
||||
}
|
||||
|
||||
// This function panic on Ok instead of Err
|
||||
func (res Result[T]) Unwrap_err() error {
|
||||
func (res Result[T]) UnwrapErr() error {
|
||||
if res.err != nil {
|
||||
return res.err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user