Allow extra fields when using #[from] (using Default trait)

オープン
#441 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
tooling

調査の方向性

まず #[from] の展開と生成される From 実装を確認し、次にエラーへのコンテキスト追加に関する過去の issue を確認します。デフォルト値が設定された追加フィールド、またはオプションの #[from] パラメーターについて、受け入れる動作について合意されて実装され、crate が意図するシンプルさを変更していなければ、作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

It would be useful to allow extra fields in the structs when using #[from], to optionally add additional context. I think that could be achieved by simply initializing them with Default::default() in the From implementation, and allowing user to add the context to errors later (e.g. with another derive macro from a different crate).

I could provide a PR that implement it, but I saw from some previous issues that you're somewhat against the idea of supporting adding context to the errors, so I want to make sure you're on board with this before I spend more time on it.

I believe that my proposal is minimally intrusive, and maintains the spirit of simplicity of this crate. If this would stray too much from the current interface, how about adding optional parameter to #[from], e.g. #[from(with_defaults)], that would trigger this behavior?

主要言語
Rust
スター
5.6k
フォーク
220
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dtolnay/thiserror のほかの issue

dtolnay/thiserror の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。