From 5b240e04573af500061180a5ac39f35285d2868b Mon Sep 17 00:00:00 2001 From: Levente Batuska Date: Sun, 5 Jan 2025 22:27:49 +0100 Subject: [PATCH] fix(Type): only require pointers where nil is meaningful other than panicking on it --- type/optional.go | 6 ++---- type/result.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/type/optional.go b/type/optional.go index 19e17b4..b801739 100644 --- a/type/optional.go +++ b/type/optional.go @@ -50,16 +50,14 @@ func (opt *Optional[T]) HasValue() bool { } // UNWRAPPABLE INTERFACE BEGIN -func (opt *Optional[T]) Expect(msg string) T { - Assert.NotNil(opt) +func (opt Optional[T]) Expect(msg string) T { if opt.present { return opt.value } panic(msg) } -func (opt *Optional[T]) Unwrap() T { - Assert.NotNil(opt) +func (opt Optional[T]) Unwrap() T { if opt.present { return opt.value } diff --git a/type/result.go b/type/result.go index 9402769..edd8227 100644 --- a/type/result.go +++ b/type/result.go @@ -49,16 +49,14 @@ func (res *Result[T]) HasValue() bool { } // UNWRAPPABLE INTERFACE -func (res *Result[T]) Expect(msg string) T { - Assert.NotNil(res) +func (res Result[T]) Expect(msg string) T { if res.err == nil { return res.value } panic(msg) } -func (res *Result[T]) Unwrap() T { - Assert.NotNil(res) +func (res Result[T]) Unwrap() T { if res.err == nil { return res.value }