diff --git a/src/editions/creating-a-new-project.md b/src/editions/creating-a-new-project.md index 59a66a1..b2bde13 100644 --- a/src/editions/creating-a-new-project.md +++ b/src/editions/creating-a-new-project.md @@ -1,52 +1,89 @@ <!-- # Creating a new project -When you create a new project with Cargo, it will automatically add -configuration for the latest edition: +A new project created with Cargo is configured to use the latest edition by +default: --> # 新しいプロジェクトを作成する -Cargoは新たなプロジェクトを作成する際に自動で最新のエディションをコンフィギュレーションに追加します。 +Cargo で新たなプロジェクトを作成すると、最新のエディションを使う設定が自動的に記述されます。 ```console -> cargo +nightly new foo - Created binary (application) `foo` project -> cat foo/Cargo.toml +$ cargo new foo + Creating binary (application) `foo` package +note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +$ cat foo/Cargo.toml [package] name = "foo" version = "0.1.0" -authors = ["your name <you@example.com>"] -edition = "2021" +edition = "2024" [dependencies] ``` <!-- -That `edition = "2021"` setting will configure your package to use Rust 2021. -No more configuration needed! +That `edition = "2024"` setting configures your package to be built using the +Rust 2024 edition. No further configuration needed! -If you'd prefer to use an older edition, you can change the value in that -key, for example: +You can use the `--edition <YEAR>` option of `cargo new` to create the project +using some specific edition. For example, creating a new project to use the +Rust 2018 edition could be done like this: --> -この `edition = "2021"` によってあなたのパッケージが Rust 2021 を利用するように設定されます。 +`edition = "2024"` で、パッケージが Rust 2024 でビルドされるよう設定されます。 これ以外は必要ありません。 -もし、他の古いエディションを使いたい場合は、その設定の値を変更できます。例えば、 +`cargo new` のオプションとして `--edition <YEAR>` を用いれば、 +新しいプロジェクトがそのエディションを使うようにできます。 +たとえば、Rust 2018 を使ったプロジェクトを作るには、以下のようにします。 -```toml +```console +$ cargo new --edition 2018 foo + Creating binary (application) `foo` package +note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +$ cat foo/Cargo.toml [package] name = "foo" version = "0.1.0" -authors = ["your name <you@example.com>"] -edition = "2015" +edition = "2018" [dependencies] ``` <!-- -This will build your package in Rust 2015. +Don't worry about accidentally using an invalid year for the edition; the +`cargo new` invocation will not accept an invalid edition year value: +--> + +うっかり存在しないエディションを指定しても大丈夫です。 +`cargo new` に存在しないエディションを指定しても弾かれます。 + +```console +$ cargo new --edition 2019 foo +error: invalid value '2019' for '--edition <YEAR>' + [possible values: 2015, 2018, 2021, 2024] + + tip: a similar value exists: '2021' + +For more information, try '--help'. +``` + +<!-- +You can change the value of the `edition` key by simply editing the +`Cargo.toml` file. For example, to cause your package to be built using the +Rust 2015 edition, you would set the key as in the following example: --> -とすると、あなたのパッケージは Rust 2015 でビルドされます。 +`Cargo.toml` の `edition` の値を直接変更しても構いません。 +たとえば、パッケージが Rust 2015 でビルドされるようにするには、以下のように設定すればよいです。 + +```toml +[package] +name = "foo" +version = "0.1.0" +authors = ["your name <you@example.com>"] +edition = "2015" + +[dependencies] +```