[Feature request] Enabling support for transitive "#[from]' handling
まだ誰も着手していません。
評価
調査の方向性
ファイルやテストのエントリポイントは指定されていません。ネストされた ConversionDbError と MyError の例から始めて、リポジトリに既存の #[from] の動作を確認してください。推移的な変換がどのように機能すべきかを定義し、ネストされたバリアントが外側のエラーに変換されることを示すテストカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
説明
I will explain myself with a very simple example :
Say I have this huge error type on my codebase :
#[derive(Error, Debug)]
pub enum MyError {
#[error("Network error: {0}")]
Network(String),
#[error("Conversion Error: {0}")]
ConversionError(#[from] ConversionDbError),
// Around 30 other variants
And with
#[derive(Error, Debug)]
pub enum ConversionDbError {
#[error("UUID conversion error: {0}")]
Uuid(#[from] uuid::Error),
#[error("UTF-8 conversion error: {0}")]
FromUtf8(#[from] std::string::FromUtf8Error),
#[error("TryFromIntError conversion error: {0}")]
TryFromInt(#[from] std::num::TryFromIntError),
}
I still need to add the manual conversions in order to forward the error down my enum :
impl From<uuid::Error> for DbError {
fn from(e: uuid::Error) -> Self {
Self::ConversionError(ConversionDbError::Uuid(e))
}
}
// and the 2 others
This kindof takes away my goal from importing the thiserror crate, which is to reduce boilerplate redundant code to the maximum. Of course, the code above isn't my production code. My code is so huge that this kind of feature will make it way more human-friendly.
Am I doing smth wrong or this is a feature that can be implemented ?
- 主要言語
- Rust
- スター
- 5.6k
- フォーク
- 220
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dtolnay/thiserror のほかの issue
-
Improve #[from] documentation example.対応中かも @SatvikMishra08 が 50 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
No `unused field` warnings are produced on enums deriving thiserror::Error対応中かも @usmanovbf が 240 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
dtolnay/thiserror の issue をすべて見る
似ている issue
-
Selected chart highlights only its values, not its series names and category labels対応中かも @Higgs32584 が今日担当しました。 オープンbug priority: low ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
storytold/gridcraft#4390 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
bug bugfix priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
quarto-dev/q2#1219 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100