File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1292,11 +1292,15 @@ impl<T> SizedTypeProperties for T {}
1292
1292
1293
1293
/// Expands to the offset in bytes of a field from the beginning of the given type.
1294
1294
///
1295
- /// Only structs , unions and tuples are supported.
1295
+ /// Structs, enums , unions and tuples are supported.
1296
1296
///
1297
1297
/// Nested field accesses may be used, but not array indexes like in `C`'s `offsetof`.
1298
1298
///
1299
- /// Note that the output of this macro is not stable, except for `#[repr(C)]` types.
1299
+ /// Enum variants may be traversed as if they were fields. Variants themselves do
1300
+ /// not have an offset.
1301
+ ///
1302
+ /// Note that type layout is, in general, [platform-specific, and subject to
1303
+ /// change](https://doc.rust-lang.org/reference/type-layout.html).
1300
1304
///
1301
1305
/// # Examples
1302
1306
///
@@ -1324,6 +1328,8 @@ impl<T> SizedTypeProperties for T {}
1324
1328
/// struct NestedB(u8);
1325
1329
///
1326
1330
/// assert_eq!(mem::offset_of!(NestedA, b.0), 0);
1331
+ ///
1332
+ /// assert_eq!(mem::offset_of!(Option<&u8>, Some.0), 0);
1327
1333
/// ```
1328
1334
#[ unstable( feature = "offset_of" , issue = "106655" ) ]
1329
1335
#[ allow_internal_unstable( builtin_syntax, hint_must_use) ]
You can’t perform that action at this time.
0 commit comments