MapValues provides the entries of the map via key-value callback.
(cbCons func(Constant, Constant) error, cbNil func() error)
| 520 | |
| 521 | // MapValues provides the entries of the map via key-value callback. |
| 522 | func (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. |
| 539 | func (c Constant) StructValues(cbCons func(Constant, Constant) error, cbNil func() error) (error, error) { |