fix failing tests

This commit is contained in:
Max Känner 2024-08-16 18:44:04 +02:00
parent aa1b8d9272
commit 10d0750678

View File

@ -102,7 +102,7 @@ impl ConfigField {
impl #ident {
pub fn new(value: #ty) -> Option<Self> {
if (#min..=#max).contains(&value) {
Self(value)
Some(Self(value))
} else {
None
}
@ -165,7 +165,7 @@ impl ConfigField {
let conversion = if self.has_custom_limits() {
quote! {
Self::new(value).ok_or_else(|| {
<D:Error as ::serde::de::Error>::custom("checking value bounds")
<D::Error as ::serde::de::Error>::custom("checking value bounds")
})
}
} else {
@ -213,8 +213,8 @@ impl ConfigField {
(stringify!($field),
value.clone().explicit().map(|val| {
parse_quote!({
let val: #ty = #val;
val
fn type_ascribe(val: #ty) -> #ty {val}
type_ascribe(#val)
})
}).unwrap_or_else(|| {
parse_quote!(#ty::$default)
@ -290,7 +290,7 @@ impl ConfigField {
.enumerate()
.map(|(i, (_, expr))| {
quote! {
#i => #expr.serialize(ser).map_err(|err| ::miniconf::Error::Inner(0, err)),
#i => ::serde::Serialize::serialize(&#expr, ser).map_err(|err| ::miniconf::Error::Inner(0, err)),
}
})
.collect::<Vec<_>>();
@ -307,7 +307,7 @@ impl ConfigField {
S: ::serde::Serializer,
{
let ::core::result::Result::Ok(key) = keys.next::<Self>() else {
return self.serialize(ser).map_err(|err| ::miniconf::Error::Inner(1, err)).map(|_| 1);
return ::serde::Serialize::serialize(&self, ser).map_err(|err| ::miniconf::Error::Inner(1, err)).map(|_| 1);
};
let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?;
if !keys.finalize() {
@ -338,7 +338,7 @@ impl ConfigField {
D: ::serde::Deserializer<'de>,
{
let ::core::result::Result::Ok(key) = keys.next::<Self>() else {
*self = Self::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))?;
@ -347,7 +347,7 @@ impl ConfigField {
}
match index {
0 => {
*self = Self::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)
}
,