I would like to share the domain(entity) logic with the code cli and wasm in Rust.
However, since we have to give
#[wasm_bindgen] to the wasm function, we control which functions are generated by whether or not the target is wasm as follows:
Excerpts from domain.rs
If true, I would like to control whether or not
#[wasm_bindgen] is given to centralize functions, but
#[cfg(target_family="wasm")] should not be able to control the attribute alone.
(Please let me know if there is a way I can do it)
Is there a good way?rust webassembly
#[cfg_attr(a,b)] is likely to work.
# If [cfg(a)] is enabled, it will do #[b], so I think it matches the case of the question.
Materials (in English...)
© 2022 OneMinuteCode. All rights reserved.