Rust
安装
export CARGO_HOME=/opt/env/cargo
export RUSTUP_HOME=/opt/env/rustup
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
export PATH=$CARGO_HOME/bin:$PATH
[[ -x rustup ]] && source <(rustup completions bash)
mkdir -pv ${CARGO_HOME}
cat <<- 'EOF' | tee ${CARGO_HOME}/config.toml > /dev/null
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[source.crates-io]
replace-with = "tuna"
EOF
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
工具
cargo-binstall

cargo install cargo-binstall
WASM

cargo binstall wasm-pack
wasm-pack new wasm-demo
wasm-pack build --target web
<script type="module">
import init, {greet} from "./pkg/wasm_demo.js";
init().then(() => {
greet('hello');
});
</script>
收藏