Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
[package]
name = "hello_cargo"
version = "0.1.0"
edition = "2021"

[dependencies]                


Building

Code Block
themeEmacs
cargo build


Build and Run

Code Block
themeEmacs
cargo run

Build for Release 

Code Block
themeEmacs
cargo build --release

This command will create an executable in target/release instead of target/debug. The optimizations make your Rust code run faster, but turning them on lengthens the time it takes for your program to compile. This is why there are two different profiles: one for development, when you want to rebuild quickly and often, and another for building the final program you’ll give to a user that won’t be rebuilt repeatedly and that will run as fast as possible. If you’re benchmarking your code’s running time, be sure to run cargo build --release and benchmark with the executable in target/release.




References

ReferenceURL
The Rust Programming Languagehttps://doc.rust-lang.org/book/title-page.html