LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

cargo-init

Create a new Rust package in an existing directory

TLDR

Initialize in current directory
$ cargo init
copy
Initialize binary project
$ cargo init --bin
copy
Initialize library
$ cargo init --lib
copy
Initialize without git
$ cargo init --vcs none
copy
Initialize with specific name
$ cargo init --name [myproject]
copy
Initialize with specific edition
$ cargo init --edition [2021]
copy
Initialize in a specific directory
$ cargo init [path/to/dir]
copy

SYNOPSIS

cargo init [options] [path]

DESCRIPTION

cargo init creates a new Cargo package in an existing directory. Generates Cargo.toml and src/ with either main.rs (binary) or lib.rs (library). Unlike cargo new, does not create a new directory.

PARAMETERS

--bin

Create binary target with src/main.rs (default).
--lib
Create library target with src/lib.rs.
--name name
Set package name (defaults to directory name).
--edition year
Rust edition (2015, 2018, 2021, 2024).
--vcs type
Initialize version control (git, hg, pijul, fossil, none).
--registry name
Registry for publishing.
--force
Force overwrite of existing Cargo.toml or src directory.
-v, --verbose
Verbose output.
-q, --quiet
Suppress output.

GENERATED FILES

$ .
├── Cargo.toml
├── .gitignore (if using git)
└── src
    └── main.rs (or lib.rs)
copy

INSTALL

sudo apt install cargo
copy
sudo dnf install cargo
copy
sudo apk add cargo
copy
sudo zypper install cargo
copy
nix profile install nixpkgs#cargo
copy

CAVEATS

Default edition is 2024 in recent Rust versions. Initializes git repository by default if not already in one.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid