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
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -211,9 +211,32 @@ 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 at most one possible value. Examples include:
218
+
219
+
- The [unit type] (see [layout.tuple.unit]).
220
+
-[Arrays] of zero-sized types (see [layout.array]).
221
+
-[Arrays] of length zero (see [layout.array]).
222
+
-[Unions] of zero-sized types (see [items.union.common-storage]).
223
+
224
+
```rust
225
+
# usecore::mem::size_of;
226
+
unionU {
227
+
f1: (),
228
+
f2: [(); 10],
229
+
}
230
+
assert_eq!(0, size_of::<()>());
231
+
assert_eq!(0, size_of::<[(); 10]>());
232
+
assert_eq!(0, size_of::<[u8; 0]>());
233
+
assert_eq!(0, size_of::<U>());
234
+
```
235
+
214
236
[`extern` blocks]: items.extern
215
237
[`extern fn`]: items.fn.extern
216
238
[alignment]: type-layout.md#size-and-alignment
239
+
[arrays]: type.array
217
240
[associated item]: #associated-item
218
241
[attributes]: attributes.md
219
242
[*entity*]: names.md
@@ -252,5 +275,6 @@ A type is uninhabited if it has no constructors and therefore can never be insta
0 commit comments