Question

How can I set default build target for Cargo?

I tried to make 'Hello World' in Rust using this tutorial, but the build command is a bit verbose:

cargo +nightly build --target wasm32-unknown-unknown --release

Is it possible to set the default target for cargo build?

 46  59672  46
1 Jan 1970

Solution

 90

You could use a Cargo configuration file to specify a default target-triple for your project. In your project's root, create a .cargo directory and a config.toml file in it with the following contents:

[build]
target = "wasm32-unknown-unknown"

Put this in .cargo/config.toml. Not in your cargo.toml.

2018-03-23

Solution

 22

As listed in the Cargo documentation, you can create a .cargo/config and specify the target:

[build]
target = "my-custom-target"
2018-03-23