Skip to content

Iterative mutable slicing doesn't work #18902

@mahkoh

Description

@mahkoh
    {
        let mut bytes = bytes.as_mut_slice();
        for s in i.iter() {
            std::slice::bytes::copy_memory(bytes, s.as_bytes());
            bytes[s.len()] = 0;
            bytes = bytes.slice_from_mut(s.len() + 1);
        }
    }

Where the outer bytes is a vector. This code is safe and the only alternative seems to be working with raw pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions