| 227 | } |
| 228 | |
| 229 | func SetPath(data any, path Path, value any, opts *SetPathOpts) (any, error) { |
| 230 | if opts == nil { |
| 231 | opts = &SetPathOpts{} |
| 232 | } |
| 233 | if opts.Remove && opts.CombineFn != nil { |
| 234 | return nil, fmt.Errorf("SetPath: Remove and CombineFn are mutually exclusive") |
| 235 | } |
| 236 | if opts.Remove && value != nil { |
| 237 | return nil, fmt.Errorf("SetPath: Remove and value are mutually exclusive") |
| 238 | } |
| 239 | return setPathInternal(data, pathWithPos{Path: path, Index: 0}, value, *opts) |
| 240 | } |
| 241 | |
| 242 | func checkAndModifyBudget(opts *SetPathOpts, pp pathWithPos, cost int) bool { |
| 243 | if opts.Budget == 0 { |