| 66 | type Options []Option |
| 67 | |
| 68 | func (opts Options) filter(s *state, t reflect.Type, vx, vy reflect.Value) (out applicableOption) { |
| 69 | for _, opt := range opts { |
| 70 | switch opt := opt.filter(s, t, vx, vy); opt.(type) { |
| 71 | case ignore: |
| 72 | return ignore{} // Only ignore can short-circuit evaluation |
| 73 | case validator: |
| 74 | out = validator{} // Takes precedence over comparer or transformer |
| 75 | case *comparer, *transformer, Options: |
| 76 | switch out.(type) { |
| 77 | case nil: |
| 78 | out = opt |
| 79 | case validator: |
| 80 | // Keep validator |
| 81 | case *comparer, *transformer, Options: |
| 82 | out = Options{out, opt} // Conflicting comparers or transformers |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | return out |
| 87 | } |
| 88 | |
| 89 | func (opts Options) apply(s *state, _, _ reflect.Value) { |
| 90 | const warning = "ambiguous set of applicable options" |