Forrest logo
back to the cargo tool

cargo:tldr:179b4

cargo: Create a new binary or library Rust project in the specified directory.
$ cargo new ${path-to-directory} --${select}
try on your machine

This command is used in the Rust programming language's package manager called Cargo. It is used to create a new Rust project with its directory structure and initial files.

Let's break down the command:

  • cargo new: This is the main command to create a new project using Cargo.
  • ${path-to-directory}: This is the placeholder for the user to provide the desired path or directory name where they want to create the project. This can be an absolute or relative path.
  • --${select}: This part of the command is optional and allows the user to select a template for the new project. The ${select} placeholder represents the template name. Templates are usually specified as --template <name>, where <name> can be a predefined template provided by Rust community or a custom template added by the user.

For example, if you want to create a new project named "my_project" in your current working directory without using any specific template, you would run:

cargo new my_project

If you want to create a project named "my_project" using a specific template, let's say "web", you would run:

cargo new my_project --template web
This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the cargo tool