-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I'm using confy 0.3.1, and it seems that I am unable to remove items from a vec in my config (adding items works fine). But when I was trying to build a simple example to demonstrate the issue, I found a very confusing one.
Here's my code:
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct MyItem {
name: String,
}
#[derive(Debug, Serialize, Deserialize)]
struct MyConfig {
items: Vec<MyItem>,
}
/// `MyConfig` implements `Default`
impl ::std::default::Default for MyConfig {
fn default() -> Self {
Self {
items: vec![MyItem { name: "foo".into() }, MyItem { name: "bar".into() }],
}
}
}
fn main() -> Result<(), ::std::io::Error> {
let mut cfg: MyConfig = confy::load("foobar")?;
println!("{:?}", cfg);
cfg.items.remove(0);
println!("{:?}", cfg);
confy::store("foobar", cfg)?;
Ok(())
}
This is what I get in the config file after running it (any number of times):
[[items]]
name = 'bar'
[[items]]
name = 'bar'I expected one item after the first run and zero after subsequent runs. And the default vec has two different items (foo and bar) whereas the toml file have the same item twice.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working