34 lines
496 B
Go
34 lines
496 B
Go
package myRedis
|
|
|
|
type IntResult struct {
|
|
Result int64
|
|
Err error
|
|
}
|
|
|
|
func NewIntResult(result int64, err error) *IntResult {
|
|
return &IntResult{Result: result, Err: err}
|
|
}
|
|
|
|
func (t *IntResult) Unwrap() int64 {
|
|
if t.Err != nil {
|
|
panic(t.Err)
|
|
}
|
|
|
|
return t.Result
|
|
}
|
|
|
|
func (t *IntResult) UnwrapOr(str int64) int64 {
|
|
if t.Err != nil {
|
|
return str
|
|
} else {
|
|
return t.Result
|
|
}
|
|
}
|
|
|
|
func (t *IntResult) UnwrapOrElse(f func() int64) int64 {
|
|
if t.Err != nil {
|
|
return f()
|
|
}
|
|
return t.Result
|
|
}
|