Skip to content

Box is missing leak_with_allocator #134

@matthewpipie

Description

@matthewpipie

Box::leak is defined as

unsafe { &mut *Box::into_raw(b) }

However, there is no way to extract the allocator while leaking without using the underlying Box::into_raw_with_allocator, which returns (*mut T, A). I propose adding Box::leak_with_allocator, which returns (&mut T, A) by calling into_raw_with_allocator and performing the unsafe cast.

Any thoughts on this? Happy to make a PR if this is something that others think is a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions