Coder Social home page Coder Social logo

rustbook's Issues

実践Rustプログラミング入門(第1版第5刷)でコンパイルエラー

はじめまして、
実践Rustプログラミング入門(第1版第5刷)
で学習をしておりますが、

本書の通りに書いたにも関わらず、
Chapter4 のderiveマクロを使った記述方式で以下のエラーが発生しました。

error_log.txt

自分でも調べてみましたが原因が分からず行き詰まっております。

大変お忙しい中恐縮ですが、
解決策等お願い致します。

Chapter4の手順通りにコマンドを実行したがエラーになる

実践的な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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.