Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Field defaults overwrite explicitly selected unit enum variants

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
backend

調査の方向性

Start at the derived Configuration implementation for enums and inspect how contains_non_secret_data() treats unit variants. Add a regression test using the issue’s LogFormat example and field default. Done means the explicitly configured Json value survives try_build() instead of being replaced by Plain.

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

説明

The Configuration derive returns false from contains_non_secret_data() for unit enum variants. This causes #[confik(default = …)] to overwrite explicit values—for example, configured LogFormat::Json becomes the default LogFormat::Plain.

An explicitly selected variant should count as supplied data and take precedence over the field default.

This works:

// Cargo.toml:
// confik = "=0.15.12"
// serde = { version = "1", features = ["derive"] }

use confik::{Configuration, TomlSource};

#[derive(Debug, PartialEq, serde::Deserialize)]
#[serde(rename_all = "lowercase")]
enum LogFormat {
    Plain,
    Json,
}

impl Configuration for LogFormat {
    type Builder = Option<Self>;
}

#[derive(Configuration)]
struct Config {
    #[confik(default = LogFormat::Plain)]
    format: LogFormat,
}

fn main() {
    let config = Config::builder()
        .override_with(TomlSource::new(r#"format = "json""#))
        .try_build()
        .unwrap();

    assert_eq!(config.format, LogFormat::Json);
}

This doesn’t — a derived implementation with the same field default:

// Cargo.toml: confik = "=0.15.12"

use confik::{Configuration, TomlSource};

#[derive(Debug, PartialEq, Configuration)]
#[confik(forward(serde(rename_all = "lowercase")))]
enum LogFormat {
    Plain,
    Json,
}

#[derive(Configuration)]
struct Config {
    #[confik(default = LogFormat::Plain)]
    format: LogFormat,
}

fn main() {
    let config = Config::builder()
        .override_with(TomlSource::new(r#"format = "json""#))
        .try_build()
        .unwrap();

    // Fails: left is Plain, right is Json.
    assert_eq!(config.format, LogFormat::Json);
}
主要言語
Rust
スター
46
フォーク
3
平均マージ
19時間 35分
マージ済み PR(30日)
27

環境構築

はじめの一歩

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

x52dev/confik のほかの issue

x52dev/confik の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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