Skip to content

mem::{size,align,min_align}_of_val should accept DSTs #19063

Closed
@ftxqxd

Description

@ftxqxd

Currently, mem::size_of_val and friends only support sized types, and just defer to mem::size_of etc.. Ideally, they would also support dynamically-sized types, in a way such that size_of_val(&[1, 2, 3]: &[int]) == size_of::<int>() * 3. Because this requires an actual value, they wouldn’t be able to simply defer to calling size_of etc. and would instead have to become intrinsic functions. I believe that this issue makes implementing pointer types that accept dynamically-sized type parameters very difficult (if not impossible) (e.g., #18248 (although I think that also might require a way of running destructors for unsized values)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DSTsArea: Dynamically-sized types (DSTs)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions