blob: 78c4448b4c26facb3a1f0ec3707364e3e9b0a762 [file] [log] [blame]
cue eval -c structs.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Structs"
description = ""
-- text.md --
Struct is the most important composite type in CUE.
It's members are called fields.
A struct field may be optional.
One can use an optional field to indicate what the type should be if it were
specified.
A regular (or required) field, on the other hand, must be made concrete
for a configuration to be converted to, say, JSON.
It is okay for an optional field to be bottom (`_|_`).
This just means that field may not be specified.
-- structs.cue --
#a: {
foo?: int
bar?: string
baz?: string
}
b: #a & {
foo: 3
baz?: 2 // baz?: _|_
}
-- expect-stdout-cue --
b: {
foo: 3
}