Rust is a powerful and memory-safe programming language used for systems programming, tools, and high-performance applications. Termux lets you install Rust easily so you can write, compile, and run Rust programs directly on your Android device. Below are the installation steps and the basic commands you need.
Installation
Update Termux packages:
pkg update && pkg upgrade -yInstall Rust using rustup:
pkg install rust -yCheck Rust version:
rustc --versionCheck Cargo version:
cargo --versionCreate a new Rust file:
nano hello.rsAdd this code:
fn main() {
println!("Hello Termux!");
}Compile the program:
rustc hello.rsRun it:
./helloBasic Commands
Run a Rust file directly (without compiling):
cargo runCreate a new Cargo project:
cargo new projectnameBuild a Cargo project:
cargo buildBuild for release:
cargo build --releaseUpdate Rust and Cargo:
rustup updateUninstall Rust:
pkg uninstall rust