Equivalent of `cfg_select`?

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

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

評価

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

調査の方向性

まず、提案されている rustversion::cfg_select! の構文と、属性または任意の式が受け付けられない Rust の文法コンテキストを確認します。要求された動作を std::cfg_select! と比較し、stable および nightly Rust でジェネリック引数の例を検証します。プロジェクトが、コンパイラのバージョンに応じて適切な型構文を選択するための、決定済みでテストされたアプローチを持つことが完了の条件です。

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

説明

There are some contexts where the grammar of rust allows one macro, but not arbitrary expressions, e.g. attributes on expressions and impl heads.

Is there an interest in a cfg_select! macro that does the equivalent of std::cfg_select! for rust versions?

rustversion::cfg_select! {
    nightly => { Vec<T, A> }, 
    _       => { Vec<T> },
}
// expands on nightly to
// Vec<T, A>
// on stable to
// Vec<T>

Note in the example above that attributes are not allowed on generic arguments, hence naming the full type. A type alias is also not a good option since rust checks that all parameters are used and errors when the optional allocator argument is unused.

Would be interested in this and follow up with a PR if you are too.

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

環境構築

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

はじめの一歩

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

dtolnay/rustversion のほかの issue

dtolnay/rustversion の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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