refactor: naming (#1)

This commit was merged in pull request #1.
This commit is contained in:
Levente Nas
2024-09-25 09:42:06 +02:00
committed by GitHub
parent 23a8a9ee04
commit c4b6077e3a
11 changed files with 122 additions and 122 deletions

View File

@@ -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
}