Compare commits

...

2 Commits
v0.3.5 ... main

3 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "macroconf" name = "macroconf"
version = "0.3.5" version = "0.3.6"
edition = "2021" edition = "2021"
description = "macro for creating configurations using miniconf" description = "macro for creating configurations using miniconf"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"

View File

@ -647,7 +647,7 @@ impl Enum {
D: ::serde::Deserializer<'de>, D: ::serde::Deserializer<'de>,
{ {
let ::core::result::Result::Ok(key) = keys.next::<Self>() else { 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); return ::core::result::Result::Ok(0);
}; };
let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?; let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?;
@ -656,7 +656,7 @@ impl Enum {
} }
match index { match index {
0 => { 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) Ok(0)
} }
1..=#num_keys => ::core::result::Result::Err(::miniconf::Traversal::Access(0, "Cannot write limits").into()), 1..=#num_keys => ::core::result::Result::Err(::miniconf::Traversal::Access(0, "Cannot write limits").into()),

View File

@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use std::str::from_utf8; use std::str::from_utf8;
/// Description /// Description
#[derive(Default, ConfigEnum, Serialize, Deserialize)] #[derive(Debug, Default, PartialEq, Eq, ConfigEnum, Serialize, Deserialize)]
enum Test { enum Test {
#[default] #[default]
Variant1, Variant1,
@ -56,4 +56,7 @@ fn deserialize(
let res = config.set_json(path, b"\"Variant3\""); let res = config.set_json(path, b"\"Variant3\"");
assert_eq!(res, expected); assert_eq!(res, expected);
if res.is_ok() {
assert_eq!(config, Test::Variant3);
}
} }