size_of_val_raw: for length 0 this is safe to call

This commit is contained in:
Ralf Jung
2024-06-08 11:26:10 +02:00
parent cd3d98b3be
commit 287b66b0b5
4 changed files with 32 additions and 0 deletions

View File

@@ -183,6 +183,8 @@ impl Layout {
/// - a [slice], then the length of the slice tail must be an initialized
/// integer, and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// For the special case where the dynamic tail length is 0, this function
/// is safe to call.
/// - a [trait object], then the vtable part of the pointer must point
/// to a valid vtable for the type `T` acquired by an unsizing coercion,
/// and the size of the *entire value*