You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/glossary.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -211,6 +211,27 @@ r[glossary.uninhabited]
211
211
212
212
A type is uninhabited if it has no constructors and therefore can never be instantiated. An uninhabited type is "empty" in the sense that there are no values of the type. The canonical example of an uninhabited type is the [never type]`!`, or an enum with no variants `enum Never { }`. Opposite of [Inhabited](#inhabited).
213
213
214
+
r[glossary.zst]
215
+
### Zero-sized type (ZST)
216
+
217
+
A type is zero-sized (a ZST) if its size is 0. Such types have only one possible value. Examples include:
218
+
219
+
- The [unit type].
220
+
-[Unit-like structs] which have no fields.
221
+
-[Unions] of zero-sized types.
222
+
223
+
```rust
224
+
# usecore::mem::{ManuallyDrop, size_of};
225
+
structS;
226
+
unionU {
227
+
f1: (),
228
+
f2:ManuallyDrop<S>,
229
+
}
230
+
assert_eq!(0, size_of::<()>());
231
+
assert_eq!(0, size_of::<S>());
232
+
assert_eq!(0, size_of::<U>());
233
+
```
234
+
214
235
[`extern` blocks]: items.extern
215
236
[`extern fn`]: items.fn.extern
216
237
[alignment]: type-layout.md#size-and-alignment
@@ -252,5 +273,7 @@ A type is uninhabited if it has no constructors and therefore can never be insta
0 commit comments