fix(Type): only require pointers where nil is meaningful other than panicking on it

This commit is contained in:
2025-01-05 22:27:49 +01:00
parent 4855e19fb3
commit 5b240e0457
2 changed files with 4 additions and 8 deletions

View File

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

View File

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