fix(Type): only require pointers where nil is meaningful other than panicking on it
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user