Skip to content

Commit abc88ff

Browse files
author
Danilo Krummrich
committed
library: core: document layout guarantee of TypeId
Document the layout guarantee of `TypeId` not to exceed 16 bytes. This is useful for FFI use-cases where a `TypeId` may be stored within a foreign data structure or buffer. An example for such a use-case can be found in [1]. Link: https://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git/commit/?id=6f61a2637abe4f89877da3280775565baedb60e0 [1] Suggested-by: Alice Ryhl <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]>
1 parent 292db4a commit abc88ff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/any.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,10 @@ impl dyn Any + Send + Sync {
611611
/// noting that the hashes and ordering will vary between Rust releases. Beware
612612
/// of relying on them inside of your code!
613613
///
614+
/// # Layout
615+
///
616+
/// The size of `TypeId` is guaranteed not to exceed 16 bytes.
617+
///
614618
/// # Danger of Improper Variance
615619
///
616620
/// You might think that subtyping is impossible between two static types,

0 commit comments

Comments
 (0)