Follow the following steps to set up the project and install the dependencies:
- Create a new binary project named sample_rand, and enter the directory:
cargo new --bin sample_rand && cd sample_rand
- Install the cargo-edit tool that allows you to add and remove dependencies by modifying your Cargo.toml:
cargo install cargo-edit
- Install the rand dependency:
cargo add rand
- cargo add crate_name automatically adds the latest version of the dependency to the Cargo.toml file.
- Install the dependency by running the following command:
cargo run
- This step will print hello world as output, as we have not yet made any modifications to the source code.