🦀 Rust - New Project
New Project
Updated at 2025-02-01 11:58
A simple reminder for myself how to create a new Rust project.
... I use Rust infrequently and forget the exact spells that need to be cast.
# install and activate the latest version of Rust
mise shell rust@`mise ls-remote rust | tail -n1`
cargo --version
# create the crate (the package)
# decide package name and if it --bin or --lib to begin with
cargo init --bin my_app
cd my_app/
mise use rust@`mise current rust`
# add Rust source code for IDE support
rustup component add rust-src
Configure the IDE to use the Rust toolchain and standard library source code:
# ofc, replace the paths and version with your own
Toolchain Location:
/home/me/.local/share/mise/installs/rust/1.84.0/toolchains/1.84.0-x86_64-unknown-linux-gnu/bin
Standard Library Source:
/home/me/.local/share/mise/installs/rust/1.84.0/toolchains/1.84.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust
cargo run
Compiling undead v0.1.0 (/home/me/my_app)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/my_app`
Hello, world!