File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,23 @@ Like all ways to create undefined behavior in safe Rust, this is a bug.
302
302
303
303
</div >
304
304
305
+ ### The ` transparent ` Representation
306
+
307
+ The ` transparent ` representation can only be used on ` struct ` s that have a
308
+ single non-zero sized field and any number of zero-sized fields, including
309
+ [ ` PhantomData<T> ` ] .
310
+
311
+ Structs with this representation have the same layout and ABI as the single
312
+ non-zero sized field.
313
+
314
+ This is different than the ` C ` representation because
315
+ a struct with the ` C ` representation will always have the ABI of a ` C ` ` struct `
316
+ while, for example, a struct with the ` transparent ` representation with a
317
+ primitive field will have the ABI of the primitive field.
318
+
319
+ Because this representation delegates type layout to another type, it cannot be
320
+ used with any other representation.
321
+
305
322
[ `align_of_val` ] : ../std/mem/fn.align_of_val.html
306
323
[ `size_of_val` ] : ../std/mem/fn.size_of_val.html
307
324
[ `align_of` ] : ../std/mem/fn.align_of.html
@@ -312,3 +329,4 @@ Like all ways to create undefined behavior in safe Rust, this is a bug.
312
329
[ zero-variant enumerations ] : items/enumerations.html#zero-variant-enums
313
330
[ undefined behavior ] : behavior-considered-undefined.html
314
331
[ 27060 ] : https://github.com/rust-lang/rust/issues/27060
332
+ [ `PhantomData<T>` ] : special-types-and-traits.html#phantomdatat
You can’t perform that action at this time.
0 commit comments