forcia / rustbook Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
はじめまして、
実践Rustプログラミング入門(第1版第5刷)
で学習をしておりますが、
本書の通りに書いたにも関わらず、
Chapter4 のderiveマクロを使った記述方式で以下のエラーが発生しました。
自分でも調べてみましたが原因が分からず行き詰まっております。
大変お忙しい中恐縮ですが、
解決策等お願い致します。
実践的なRustの本を書いてくださりありがとうございます。
Chapter4の手順通りにコマンドを実行したはずなのですが、cargo run
を実行したところでエラーが出ました。
正誤表も確認しましたが、この件については載っていなかったので、念のため報告します。
# p.145に従ってプロジェクトを作成
cargo new samplecli
# 作成したディレクトリに移動
cd samplecli/
# p.148に従ってclap@=3.0.0-beta.2を依存関係に追加
cargo add clap@=3.0.0-beta.2
# p.152の「deriveマクロを使った記述方法」のコードをダウンロードして`src/main.rs`に上書き
curl https://raw.githubusercontent.com/forcia/rustbook/ba6ee3006dbe3efac0327058505f2bc288cbad4b/ch04/4-1/samplecli-derivemacro/src/main.rs > src/main.rs
# 実行
cargo run
上のコマンドを実行したところ、以下のようなエラーが出ました。
Compiling samplecli v0.1.0 (C:\Users\hiroki\source\repos\samplecli)
error[E0433]: failed to resolve: could not find `Args` in `clap`
--> src\main.rs:3:10
|
3 | #[derive(Clap, Debug)]
| ^^^^ could not find `Args` in `clap`
|
= note: this error originates in the derive macro `Clap` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0407]: method `into_app_for_update` is not a member of trait `clap::IntoApp`
--> src\main.rs:3:10
|
3 | #[derive(Clap, Debug)]
| ^^^^ not a member of trait `clap::IntoApp`
|
= note: this error originates in the derive macro `Clap` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0407]: method `update_from_arg_matches` is not a member of trait `clap::FromArgMatches`
--> src\main.rs:3:10
|
3 | #[derive(Clap, Debug)]
| ^^^^ not a member of trait `clap::FromArgMatches`
|
= note: this error originates in the derive macro `Clap` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0404]: expected trait, found derive macro `clap::Args`
--> src\main.rs:3:10
|
3 | #[derive(Clap, Debug)]
| ^^^^ not a trait
|
= note: this error originates in the derive macro `Clap` (in Nightly builds, run with -Z macro-backtrace for more info)
Some errors have detailed explanations: E0404, E0407, E0433.
For more information about an error, try `rustc --explain E0404`.
error: could not compile `samplecli` due to 4 previous errors
正しい解決方法かどうかは分かりませんが、以下の方法でclap_derive@=3.0.0-beta.2
を依存関係に追加したところ、上記の問題は解決しました。
cargo add clap_derive@=3.0.0-beta.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.