actually set set enum variant when deserializing
This commit is contained in:
parent
3f9599e01b
commit
abb2170186
@ -647,7 +647,7 @@ impl Enum {
|
||||
D: ::serde::Deserializer<'de>,
|
||||
{
|
||||
let ::core::result::Result::Ok(key) = keys.next::<Self>() else {
|
||||
<Self as ::serde::Deserialize>::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?;
|
||||
*self = <Self as ::serde::Deserialize>::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?;
|
||||
return ::core::result::Result::Ok(0);
|
||||
};
|
||||
let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?;
|
||||
@ -656,7 +656,7 @@ impl Enum {
|
||||
}
|
||||
match index {
|
||||
0 => {
|
||||
<Self as ::serde::Deserialize>::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?;
|
||||
*self = <Self as ::serde::Deserialize>::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?;
|
||||
Ok(0)
|
||||
}
|
||||
1..=#num_keys => ::core::result::Result::Err(::miniconf::Traversal::Access(0, "Cannot write limits").into()),
|
||||
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::str::from_utf8;
|
||||
|
||||
/// Description
|
||||
#[derive(Default, ConfigEnum, Serialize, Deserialize)]
|
||||
#[derive(Debug, Default, PartialEq, Eq, ConfigEnum, Serialize, Deserialize)]
|
||||
enum Test {
|
||||
#[default]
|
||||
Variant1,
|
||||
@ -56,4 +56,7 @@ fn deserialize(
|
||||
|
||||
let res = config.set_json(path, b"\"Variant3\"");
|
||||
assert_eq!(res, expected);
|
||||
if res.is_ok() {
|
||||
assert_eq!(config, Test::Variant3);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user