Struct
A struct is a composite data type or structure that groups related fields or values into a single unit.
Go in Practice, Second Edition
A struct is a composite Go type that groups named or anonymous fields into a single value.
- How it is used
- Represents known application data, including configuration and JSON responses, while providing a type to which behavior can be attached.
- How deep it goes
- Works through fields, anonymous structs, tags, methods, JSON mapping, and runtime inspection rather than stopping at a syntax definition.
- Examples
- Uses an inline struct, JSON-encoded data, a configuration file, interface-implementing types, and a recursive field walker.
- What you can do after
- Build it from scratch to model known data, map JSON fields, and add methods; diagnose/debug with reflection when fields need runtime inspection.
Kafka Streams in Action, Second Edition
Struct is a Kafka Connect data structure that stores record field values together with schema-defined type information.
- How it is used
- Carries schema-backed Kafka Connect record values and models nested ksqlDB event fields.
- How deep it goes
- Explains construction, field copying, schema caching, nested declarations, and dereferencing without detailing serialization internals.
- Examples
- Uses stock-ticker SourceRecords, selected-field transformations, and a nested school-event JSON schema.
- What you can do after
- Build it from scratch as a schema-backed Connect value or declare and query nested ksqlDB fields.
Read how Kafka Streams in Action, Second Edition explains struct →
Elixir in Action, Third Edition
An Elixir struct is a map-like data structure associated with a module and containing a defined set of fields.
- How it is used
- Uses structs to define precise data abstractions, distinguish instances from plain maps, and organize module functions around them.
- How deep it goes
- Explains definition, construction, access, pattern matching, updating, internal map behavior, and selected failure modes.
- Examples
- Demonstrates Fraction arithmetic and a TodoList that assigns incremental IDs while storing entries by ID.
- What you can do after
- Builds module-backed data abstractions with defined fields, pattern-matched operations, and immutable updates.
Modern C
- How it is used
- Groups related, named values when array positions would be ambiguous or the values may have different types.
- How deep it goes
- Works through type declarations, designated initialization, member access, nested structures, and pointer access; defers the broader treatment of pointers.
- Examples
- Uses named bird fields, calendar fields in `struct tm`, and a function that updates a day-of-year field.
- What you can do after
- Build it from scratch: declare a structure, initialize named members, access them with `.`, and use `->` through a structure pointer.
Refactoring to Rust
A struct is a Rust composite type that groups named fields into a single logical value and can have associated functionality.
- How it is used
- Groups related fields into values passed to functions or populated from JSON and XML.
- How deep it goes
- Defines named fields and initialization, then demonstrates moves and derived deserialization; does not develop struct methods.
- Examples
- Uses an artwork value, a JSON name-and-number record, and nested XML search results.
- What you can do after
- Build it from scratch as a named-field value, and apply it via Serde to parse JSON or XML.
DuckDB in Action
A struct is a named-field data structure in which each field has a defined data type.
- How it is used
- Uses structs to represent nested records and simplify complex-data preparation in analytical SQL workflows.
- How deep it goes
- Explains definitions, inferred schemas, unnesting, whole-STRUCT casts, field expansion, and aggregation, without detailing internal storage.
- Examples
- Demonstrates Premier League shot JSON, inferred STRUCT arrays, explicit casts, flattened views, and expected-goals aggregation.
- What you can do after
- Apply structs in DuckDB SQL to inspect, normalize, flatten, and aggregate nested JSON records.
Learn Rust in a Month of Lunches
- How it is used
- Groups related values into custom Rust types, while distinguishing that job from an enum’s selection among choices.
- How deep it goes
- Works through unit, tuple, and named forms, complete initialization, field shorthand, and methods without addressing memory layout.
- Examples
- Uses a country’s fields, positional color values, an animal with methods, and article data parsed from JSON.
- What you can do after
- Build it from scratch with struct declarations and complete initializers, then attach methods through an impl block.
Julia as a Second Language
The struct keyword is Julia syntax for defining a composite type.
- How it is used
- Defines composite types that group application data, from game characters to rocket components.
- How deep it goes
- Works through typed fields, instance creation, field access, mutability, and fixed-field performance implications.
- Examples
- Uses an archer’s typed fields and instances, a warrior type hierarchy, and a rocket assembled from component objects.
- What you can do after
- Build it from scratch: define typed composite objects, instantiate them, access their fields, and choose mutability when fields must change.
Go in Action, Second Edition
The struct keyword introduces a Go struct type declaration.
- How it is used
- Groups related values into reusable domain types, including measurements in a recipe application.
- How deep it goes
- Works through declarations, fields, literals, access, and visibility, then connects structs to larger models without detailing their runtime representation.
- Examples
- Uses a reusable person declaration and recipe measurements, then assembles ingredients and steps into a scalable recipe.
- What you can do after
- Build it from scratch: define and initialize a named struct, access its fields, and use it to represent related domain data.
Modern C, Third Edition
The struct keyword introduces or refers to a C structure type through its structure tag.
- How it is used
- Organizes related values under named fields when array positions are ambiguous or member types differ.
- How deep it goes
- Explains declarations, objects, member access, heterogeneous fields, nesting, and visibility, while deferring detailed layout and padding treatment.
- Examples
- Uses bird records, calendar timestamps, nanosecond timestamps, nested person data, and a timespec difference exercise.
- What you can do after
- Apply C structure declarations, designated initializers, dot notation, heterogeneous fields, and nested member organization.
Learn Go with Pocket-Sized Projects
A struct is a Go composite data type that groups named fields of potentially different types into one value.
- How it is used
- Organizes related inputs, expected results, and decoded JSON records into reusable Go values.
- How deep it goes
- Demonstrates declarations, nested slices, JSON tags, and decoding, but does not descend into runtime internals.
- Examples
- Uses testCase scenarios and Bookworm–Book records as concrete struct examples.
- What you can do after
- Apply it via encoding/json to represent and decode structured records, or organize reusable table-driven test cases.
Read how Learn Go with Pocket-Sized Projects explains struct →
Clojure: The Essential Reference
A Clojure struct is a map-like data structure with a defined set of keys and structural constraints.
- How it is used
- Creates many similarly shaped map-like values while avoiding repeated key declarations at each construction site.
- How deep it goes
- Defines the construction API and key constraints, then works through positional input, varying keys, accessors, equality, and exceptions.
- Examples
- Uses waypoint rows and coordinate maps to demonstrate positional construction, missing defined keys, extra keys, and accessor lookup.
- What you can do after
- Build it from scratch with create-struct or defstruct, then construct and query instances while respecting defined-key constraints.
Code Like a Pro in Rust
A compound type is a type formed by combining or grouping multiple values or component types.
- How it is used
- Uses structs to group state and attach operations behind an API.
- How deep it goes
- Explains struct forms, field visibility, methods, derived traits, and C-compatible representation; defers detailed generics.
- Examples
- Demonstrates tuple and named-field structs, visibility modifiers, receiver methods, and a zlib C struct mapping.
- What you can do after
- Build it from scratch: define stateful Rust APIs and map a C struct for a small FFI binding.
Rust in Action: Systems programming concepts and techniques
A struct is a Rust data structure that defines a composite value with named fields and their types.
- How it is used
- Models related values as one entity, especially files represented by names and byte data.
- How deep it goes
- Defines fields, instances, borrowing, memory composition, and constructors, while deferring persistent storage and detailed pointer explanations.
- Examples
- Uses File values containing String names and Vec<u8> data, simulated open/read/close operations, and File::new constructors.
- What you can do after
- Build it from scratch by defining structs, constructing instances, borrowing fields, and adding constructors or methods.
Read how Rust in Action: Systems programming concepts and techniques explains struct →
Related concepts
- data structurekind of · A data structure is an organized representation of data and its relationships that supports defined operations for storing, accessing, or modifying it.
- Mapkind of · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- concrete typekind of · A concrete type is a fully specified, directly implementable or instantiable type with a particular representation and behavior.
- defstruct macroused by · The defstruct macro defines the fields and initial values of a struct in an Elixir module.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.













