Skip to content

Mutable version of UnsafeTypedArray #360

@daboross

Description

@daboross

UnsafeTypedArray takes &[T] in the constructor, and stores that internally. It's nice for reading values efficiently, but as I understand it rustc will assume that values behind a reference are never mutated, and thus it's unsound to mutate values using an UnsafeTypedArray.

Could a similar structure be made which exposes a mutable view of an array to JS? For manual initialization code, like

let mut arr = [0u32; 3];
let mut wrapped = MutableUnsafeTypedArray::new(&mut arr);
js! {
    let vals = @{wrapped};
    vals[0] = ...;
    vals[1] = ...;
    vals[2] = ...;
};
arr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions