6. Structs are ordered by their fields
One struct is an instance of another when it has at least the same fields, with constraints at least as strict; nobody has to declare the relationship.
Whether data matches a schema, or one schema is a tighter version of another, is settled by looking at the fields. Nothing has to be declared.
A struct is a set of named fields. A municipality has a name, and a population.
A big city is stricter. Its population is an int over a million.
London fills in both fields. Its population is eight million. London is a big city, which is a municipality.
Nobody declared that. It follows from the fields. Loosely: an instance has at least the same fields, with constraints at least as strict.
Think of a paper form. Each box you fill in makes it more specific.
Adding a field does the same. A struct with a name and a population is an instance of one with only a name.
Check yourself. What two things make one struct an instance of another?
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime