mehcode / config-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Apache License 2.0
2.43k stars 206 forks source link

Internal error: entered unreachable code #424

Closed sweetyoru closed 1 year ago

sweetyoru commented 1 year ago

Version: 0.13

main.rs:

use config::Config;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
enum EType {
    E1,
    E2(u64),
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SType {
    f1: EType,
}

impl SType {
    pub fn new(path: &str) -> Self {
        let config = Config::builder()
            .add_source(config::File::with_name(path))
            .build()
            .unwrap();
        config.try_deserialize::<SType>().unwrap()
    }
}

fn main() {
    println!("{:?}", SType::new("./example.yaml"));
}

example.yaml:

f1: 'E2'

Cargo run result:

thread 'main' panicked at 'internal error: entered unreachable code', /home/yoru/.cargo/registry/src/github.com-1ecc6299db9ec823/config-0.13.3/src/de.rs:311:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
matthiasbeyer commented 1 year ago

Hi!

Thanks for your report. This is a duplicate of #126 though, I am closing this issue in favor of the mentioned one!

Thanks again!