RustPython / RustPython/Parser
Add `Node` union
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 117
- フォーク
- 38
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 1
説明
Add a new Node union that is an enum over all node types. This can be useful when implementing methods that can operate on any node. For example, Ruff's formatter has (roughly) the API format(node: AnyNode) -> String
I haven't figured out the full requirements yet, and I don't know yet if we'll need both the owned and reference versions:
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum Node {
IfStmt(ast::IfStmt),
ConstantExpr(ast::ConstantExpr),
...
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, is_macro)]
enum NodeRef<'a> {
IfStmt(&'a ast::IfStmt),
ConstantExpr(&'a ast::ConstantExpr)
...
}
Note: An alternative naming more in line with
PathandPathBufwould be to name the typesNodeBuf(owned) andNode(reference)
The enums should have the following basic methods:
if_stmt(self) -> Option<ast::IfStmt>as_if_stmt(&self) -> Option<&ast::IfStmt>const is_if_stmt(&self) -> bool
Node could also implement AsRef that returns a NodeRef
I may have time to work on this sometime soon but I wanted to put this up for discussion first to get feedback.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
既存のASTノード型を確認し、提案されている所有型のNodeと参照型のNodeRefの設計を比較してください。enum、変換メソッド、型チェックを実装する前に、命名要件と所有権要件を解決してください。サポート対象のノード型と必要なAPIについて合意され、テストで網羅されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100