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