package trim
import "cuelang.org/go/tools/trim"
Package trim removes fields that may be inferred from another mixed in value that "dominates" it. For instance, a value that is merged in from a definition is considered to dominate a value from a regular struct that mixes in this definition. Values derived from constraints and comprehensions can also dominate other fields.
A value A is considered to be implied by a value B if A subsumes the default value of B. For instance, if a definition defines a field `a: *1 | int` and mixed in with a struct that defines a field `a: 1 | 2`, then the latter can be removed because a definition field dominates a regular field and because the latter subsumes the default value of the former.
Examples:
light: [string]: { room: string brightnessOff: *0.0 | >=0 & <=100.0 brightnessOn: *100.0 | >=0 & <=100.0 } light: ceiling50: { room: "MasterBedroom" brightnessOff: 0.0 // this line brightnessOn: 100.0 // and this line will be removed }
Results in:
// Unmodified: light: [string]: { ... } light: ceiling50: { room: "MasterBedroom" }
Index ¶
Variables ¶
Functions ¶
func Files ¶
Files trims fields in the given files that can be implied from other fields, as can be derived from the evaluated values in inst. Trimming is done on a best-effort basis and only when the removed field is clearly implied by another field, rather than equal sibling fields.
Types ¶
type Config ¶
type Config struct { Trace bool }
Config configures trim options.
Source Files ¶
debug.go trim.go
- Version
- v0.12.0 (latest)
- Published
- Jan 30, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 8 hours ago –
Tools for package owners.