@@ -4,7 +4,7 @@ Low-level programming cares a lot about data layout. It's a big deal. It also pe
4
4
influences the rest of the language, so we're going to start by digging into how data is
5
5
represented in Rust.
6
6
7
- # The ` rust ` repr
7
+ ## The rust repr
8
8
9
9
Rust gives you the following ways to lay out composite data:
10
10
@@ -124,7 +124,7 @@ In principle enums can use fairly elaborate algorithms to cache bits throughout
124
124
with special constrained representations. As such it is * especially* desirable that we leave
125
125
enum layout unspecified today.
126
126
127
- # Dynamically Sized Types (DSTs)
127
+ ## Dynamically Sized Types (DSTs)
128
128
129
129
Rust also supports types without a statically known size. On the surface,
130
130
this is a bit nonsensical: Rust must know the size of something in order to
@@ -212,12 +212,12 @@ struct Foo {
212
212
For details as to * why* this is done, and how to make it not happen, check out
213
213
[ SOME OTHER SECTION] .
214
214
215
- # Alternative representations
215
+ ## Alternative representations
216
216
217
217
Rust allows you to specify alternative data layout strategies from the default Rust
218
218
one.
219
219
220
- # repr(C)
220
+ ### repr(C)
221
221
222
222
This is the most important ` repr ` . It has fairly simple intent: do what C does.
223
223
The order, size, and alignment of fields is exactly what you would expect from
@@ -241,14 +241,14 @@ still consumes a byte of space.
241
241
242
242
* This is equivalent to repr(u32) for enums (see below)
243
243
244
- # repr(packed)
244
+ ### repr(packed)
245
245
246
246
` repr(packed) ` forces rust to strip any padding it would normally apply.
247
247
This may improve the memory footprint of a type, but will have negative
248
248
side-effects from "field access is heavily penalized" to "completely breaks
249
249
everything" based on target platform.
250
250
251
- # repr(u8), repr(u16), repr(u32), repr(u64)
251
+ ### repr(u8), repr(u16), repr(u32), repr(u64)
252
252
253
253
These specify the size to make a c-like enum (one which has no values in its variants).
254
254
0 commit comments