Skip to content

Commit 4256f35

Browse files
committed
---
yaml --- r: 236067 b: refs/heads/stable c: 50d8656 h: refs/heads/master i: 236065: cdf37d9 236063: fa22405 v: v3
1 parent b302c8a commit 4256f35

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 987a8687db1a2a5a9388265a6bb5a1590a05dd69
32+
refs/heads/stable: 50d8656945513c6b327122e5a40650c66baa87cb
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/exotic-sizes.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Most of the time, we think in terms of types with a fixed, positive size. This
44
is not always the case, however.
55

6+
7+
8+
9+
610
# Dynamically Sized Types (DSTs)
711

812
Rust also supports types without a statically known size. On the surface,
@@ -34,19 +38,20 @@ a variable position based on its alignment.**
3438

3539

3640

41+
42+
3743
# Zero Sized Types (ZSTs)
3844

3945
Rust actually allows types to be specified that occupy *no* space:
4046

4147
```rust
4248
struct Foo; // No fields = no size
43-
enum Bar; // No variants = no size
4449

4550
// All fields have no size = no size
4651
struct Baz {
4752
foo: Foo,
48-
bar: Bar,
49-
qux: (), // empty tuple has no size
53+
qux: (), // empty tuple has no size
54+
baz: [u8; 0], // empty array has no size
5055
}
5156
```
5257

@@ -67,3 +72,16 @@ standard allocators (including jemalloc, the one used by Rust) generally conside
6772
passing in `0` as Undefined Behaviour.
6873

6974

75+
76+
77+
78+
# Void Types
79+
80+
Rust also enables types to be declared that *cannot even be instantiated*. These
81+
types can only be talked about at the type level, and never at the value level.
82+
83+
```rust
84+
enum Foo { } // No variants = VOID
85+
```
86+
87+
TODO: WHY?!

0 commit comments

Comments
 (0)