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

Method MapValues

ast/ast.go:522–536  ·  view source on GitHub ↗

MapValues provides the entries of the map via key-value callback.

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

Source from the content-addressed store, hash-verified

520
521// MapValues provides the entries of the map via key-value callback.
522func (c Constant) MapValues(cbCons func(Constant, Constant) error, cbNil func() error) (error, error) {
523 if c.Type != MapShape {
524 return fmt.Errorf("not a map constant %v", c), nil
525 }
526 for ; !c.IsMapNil(); c = *c.snd {
527 p := c.fst
528 if p.Type != PairShape {
529 return fmt.Errorf("not a struct field %v", p), nil
530 }
531 if err := cbCons(*p.fst, *p.snd); err != nil {
532 return nil, err
533 }
534 }
535 return nil, cbNil()
536}
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) {

Callers 5

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

Calls 1

IsMapNilMethod · 0.95

Tested by 1

TestReducerCollectToMapFunction · 0.64