Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add empty structs #2569

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/user-defined-types/tuple-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
minutes: 10
---

<!-- NOTES:
Tuple structs, newtype wrappers, unit-like structs, including initialization syntax
-->

# Tuple Structs

If the field names are unimportant, you can use a tuple struct:
Expand Down Expand Up @@ -52,6 +48,12 @@ fn main() {
- Rust generally doesn’t like inexplicit things, like automatic unwrapping or
for instance using booleans as integers.
- Operator overloading is discussed on Day 3 (generics).
- When a tuple struct has zero fields, the `()` can be omitted. The result is a
zero-sized type (ZST), of which there is only one value (the name of the
type).
- This is common for types that implement some behavior but have no data
(imagine a `NullReader` that implements some reader behavior by always
returning EOF).
- The example is a subtle reference to the
[Mars Climate Orbiter](https://en.wikipedia.org/wiki/Mars_Climate_Orbiter)
failure.
Expand Down
Loading