Skip to content

Commit 6be4012

Browse files
authored
Web: use safe method to copy to MaybeUninit (#584)
This removes the last `unsafe` call in the Web implementation. See [`Uint8Array::copy_to_uninit`](https://docs.rs/js-sys/0.3.77/js_sys/struct.Uint8Array.html#method.copy_to_uninit).
1 parent 2648e60 commit 6be4012

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ windows-targets = "0.52"
6262
[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))'.dependencies]
6363
wasm-bindgen = { version = "0.2.98", default-features = false }
6464
[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", any(target_os = "unknown", target_os = "none"), target_feature = "atomics"))'.dependencies]
65-
js-sys = { version = "0.3.75", default-features = false }
65+
js-sys = { version = "0.3.77", default-features = false }
6666
[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))'.dev-dependencies]
6767
wasm-bindgen-test = "0.3"
6868

src/backends/wasm_js.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
4949
return Err(Error::WEB_CRYPTO);
5050
}
5151

52-
// SAFETY: `sub_buf`'s length is the same length as `chunk`
53-
unsafe { sub_buf.raw_copy_to_ptr(chunk.as_mut_ptr().cast::<u8>()) };
52+
sub_buf.copy_to_uninit(chunk);
5453
}
5554
Ok(())
5655
}

0 commit comments

Comments
 (0)