Does Arc work when targetting the HTML5 using wasm_bindgen?
If there was a playground for that (not play.rust-lang.org), I'd not need to ask this.
What ChatGPT says:
As of my last update in September 2021, the Rust Arc type is specific to the Rust programming language and is not natively available in web browsers like Chrome, Firefox, or Safari. The Arc type stands for "atomic reference-counted smart pointer" and is used for managing shared ownership of data across threads in Rust.
Interesting... but the compiler explorer has no wasm32-unknown-unknown target installed. Even if I used wasm_bindgen though, what do atomic loads map to in the standard library anyway when target_arch = "wasm32"?
No: it does not actually provide thread-safety, which is fine as long as you don't use any threads (which is easy to obey because std doesn't offer creating threads).
The std for wasm32-unknown-unknown was written at a time before “threads in wasm in the browser” was a practical thing to accomplish. Therefore, all of the std::sync operations are stubbed out: Arc works like Rc, and Mutex and RwLock work like RefCell.
Making these things work will require fully supporting atomics-in-WASM: