MCPcopy
hub / github.com/google/mangle / StructValues

Method StructValues

ast/ast.go:539–553  ·  view source on GitHub ↗

StructValues provides the entries that make up the struct via label-value callback.

(cbCons func(Constant, Constant) error, cbNil func() error)

Source from the content-addressed store, hash-verified

537
538// StructValues provides the entries that make up the struct via label-value callback.
539func (c Constant) StructValues(cbCons func(Constant, Constant) error, cbNil func() error) (error, error) {
540 if c.Type != StructShape {
541 return fmt.Errorf("not a struct constant %v", c), nil
542 }
543 for ; !c.IsStructNil(); c = *c.snd {
544 p := c.fst
545 if p.Type != PairShape {
546 return fmt.Errorf("not a map entry %v", p), nil
547 }
548 if err := cbCons(*p.fst, *p.snd); err != nil {
549 return nil, err
550 }
551 }
552 return nil, cbNil()
553}
554
555func (c Constant) isBaseTerm() {
556}

Callers 4

boundOfArgFunction · 0.80
HasTypeMethod · 0.80
matchFunction · 0.80
EvalApplyFnFunction · 0.80

Calls 1

IsStructNilMethod · 0.95

Tested by

no test coverage detected