Skip to content

Safe memset for slices #2067

Closed
Closed
@sethjackson

Description

@sethjackson

RFC 1419 implemented safe memcpy but not memset.
It would be awesome if we could fill slices with data in a safe manner that would lower into memset.

Currently if I want to fill a slice with memset semantics I have to do this:

unsafe {
    ptr::write_bytes(self.slice.as_mut_ptr(), 0, self.slice.len() - 1);
}

I would like to be able to do something like this:

self.slice.fill(0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions