Added extra comments on what can be Send/Sync

This commit is contained in:
Syrus Akbary
2023-03-03 13:50:15 -08:00
parent 69f5ec3981
commit 8cbd9b6982
6 changed files with 36 additions and 1 deletions

View File

@@ -45,7 +45,16 @@ pub struct Module {
raw_bytes: Option<Bytes>,
}
// Module implements `structuredClone` in js, so it's safe it to make it Send.
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
// ```js
// const module = new WebAssembly.Module(new Uint8Array([
// 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00
// ]));
// structuredClone(module)
// ```
unsafe impl Send for Module {}
unsafe impl Sync for Module {}
impl Module {
pub(crate) fn from_binary(