We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de4f5c2 commit 1862054Copy full SHA for 1862054
core/src/mem/mod.rs
@@ -1266,6 +1266,20 @@ impl<T> SizedTypeProperties for T {}
1266
/// // ^^^ error[E0616]: field `private` of struct `Struct` is private
1267
/// ```
1268
///
1269
+/// Only [`Sized`] fields are supported, but the container may be unsized:
1270
+/// ```
1271
+/// # use core::mem;
1272
+/// #[repr(C)]
1273
+/// pub struct Struct {
1274
+/// a: u8,
1275
+/// b: [u8],
1276
+/// }
1277
+///
1278
+/// assert_eq!(mem::offset_of!(Struct, a), 0); // OK
1279
+/// // assert_eq!(mem::offset_of!(Struct, b), 1);
1280
+/// // ^^^ error[E0277]: doesn't have a size known at compile-time
1281
1282
1283
/// Note that type layout is, in general, [subject to change and
1284
/// platform-specific](https://doc.rust-lang.org/reference/type-layout.html). If
1285
/// layout stability is required, consider using an [explicit `repr` attribute].
0 commit comments