Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an unsafe method view_mut_raw #1850

Merged
merged 7 commits into from
Nov 6, 2019
Merged

Add an unsafe method view_mut_raw #1850

merged 7 commits into from
Nov 6, 2019

Conversation

lshlyapnikov
Copy link
Contributor

@lshlyapnikov lshlyapnikov commented Nov 4, 2019

See #1643

TODO:

  • add Uint8Array::view_mut_raw test
  • add Int16Array::view_mut_raw test
  • add Uint32Array::view_mut_raw test
  • add Float64Array::view_mut_raw test

@alexcrichton
Copy link
Contributor

Looking good!

I'd be happy to merge when you're ready!

@lshlyapnikov lshlyapnikov marked this pull request as ready for review November 6, 2019 02:10
///
/// Additionally the returned object can be safely mutated,
/// the changes are guranteed to be reflected in the input array.
pub unsafe fn view_mut_raw(ptr: *mut $ty, length: usize) -> $name {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcrichton please doublecheck the rustdoc.

@alexcrichton
Copy link
Contributor

Looks great to me, thanks!

@alexcrichton alexcrichton merged commit d51f539 into rustwasm:master Nov 6, 2019
@mstange
Copy link
Contributor

mstange commented Nov 7, 2019

Thank you!

josephlr added a commit to rust-random/getrandom that referenced this pull request Oct 23, 2022
We can use
[`Uint8Array::view_mut_raw`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Uint8Array.html#method.view_mut_raw)
which was
[added](rustwasm/wasm-bindgen#1850) in version
`0.2.54` of `wasm-bindgen`. This method was introduced to deal with
uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey <joerichey@google.com>
josephlr added a commit to rust-random/getrandom that referenced this pull request Oct 23, 2022
We can use
[`Uint8Array::view_mut_raw`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Uint8Array.html#method.view_mut_raw)
which was
[added](rustwasm/wasm-bindgen#1850) in version
`0.2.54` of `wasm-bindgen`. This method was introduced to deal with
uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey <joerichey@google.com>
josephlr added a commit to rust-random/getrandom that referenced this pull request Oct 23, 2022
We can use
[`Uint8Array::view_mut_raw`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Uint8Array.html#method.view_mut_raw)
which was
[added](rustwasm/wasm-bindgen#1850) in version
`0.2.54` of `wasm-bindgen`. This method was introduced to deal with
uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey <joerichey@google.com>
josephlr added a commit to rust-random/getrandom that referenced this pull request Oct 23, 2022
We can use
[`Uint8Array::view_mut_raw`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Uint8Array.html#method.view_mut_raw)
which was
[added](rustwasm/wasm-bindgen#1850) in version
`0.2.54` of `wasm-bindgen`. This method was introduced to deal with
uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey <joerichey@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants