Skip to content

Fields with camelCase doesn't work #65

Description

@vjousse

Hi there,
I'm new to rust and config-rs, and I'm facing an annoying problem: I can't get structs with #[serde(rename_all = "camelCase")] to work.
I've setup a simple demo repository here to illustrate my problem.
My Toml:

snakeTest = "foo"

My struct:

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct Settings {
    snake_test: String,
}

My main:

fn main() {
    let mut c = config::Config::default();
    c.merge(config::File::new("Settings", config::FileFormat::Toml))
        .unwrap();

    // Deserialize the entire file as single struct
    let s: Settings = c.try_into::<Settings>().unwrap();

    println!("{:?}", s);
}

The error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: missing field `snakeTest`', libcore/result.rs:916:5

Am I missing something? Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions