How to Choose a License for Your Rust Crate

Add the license field to your Cargo.toml file using a standard SPDX identifier like MIT OR Apache-2.0 to allow others to use your crate.

Add a license field to the [package] section of your Cargo.toml file using a valid SPDX identifier. For open-source crates, MIT OR Apache-2.0 is the standard choice used by the Rust project itself.

[package]
name = "my_crate"
version = "0.1.0"
edition = "2024"
license = "MIT OR Apache-2.0"

If you are not publishing to crates.io, you can omit this field, but it is required for public releases.