We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
anyhow::Result
The text was updated successfully, but these errors were encountered:
main 関数内ではそれ以上伝播させる必要はないから、unwrap してしまってもよいのではと考えている。
ほぼ同意です。ただし「main の中でほぼ全部のResultを unwrap している」となると、 ? を使ったほうが(関数分割したときなどに)良いなと思ってしまいます。
?
unwrap は「こういう値は絶対来ないはずで、来たら何かがおかしいと言えるから unwrap しておく」みたいな箇所にも使うことがある。
このケースはどちらかというと expect("絶対来ない理由") と書いたほうが良いプラクティスかと思います。 ただし強制するほどのことでもないとは思います。
expect("絶対来ない理由")
anyhow 使うか問題 個人的には、 #39 にてある程度エラー型が共通化されたタイミングで使うのをやめたいと思っている。
ほぼ全面同意です。 共通エラーは用意しつつも学習用途ですし、Error型を自前で定義するのも良い勉強になるかと思うので使わなくても良い程度のものでイメージしています。 (ただしError型を使えばもっときれいに書けるようなケースでは積極的な使用をレビューで推奨)
ちなみに共通エラーは
したようなものと考えて良いでしょうか?
Sorry, something went wrong.
はい、共通のエラーは下記2点を想定しています。
Errorトレイトを実装 Fromstd::io::Error, Fromstd::fmt::Error など、よくあるエラーからの変換を実装
No branches or pull requests
anyhow::Result
に一瞬面食らうと思うため。The text was updated successfully, but these errors were encountered: