1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/pkg/compiler/result.go

31 lines
461 B
Go
Raw Normal View History

2018-09-18 22:42:38 +02:00
package compiler
type visitorFn func() (interface{}, error)
type result struct {
data interface{}
err error
}
func newResult(data interface{}, err error) *result {
return &result{data, err}
}
func newResultFrom(fn visitorFn) *result {
out, err := fn()
return &result{out, err}
}
func (res *result) Ok() bool {
return res.err == nil
}
func (res *result) Data() interface{} {
return res.data
}
func (res *result) Error() error {
return res.err
}