Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Nov 21, 2024
1 parent 073b14d commit e61e257
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions miniconf_derive/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl TreeField {
{
None
} else {
let bound: Option<syn::TraitBound> = match traite {
match traite {
TreeTrait::Key => Some(parse_quote!(::miniconf::TreeKey)),
TreeTrait::Serialize => self
.deny
Expand All @@ -76,8 +76,8 @@ impl TreeField {
.then_some(parse_quote!(::miniconf::TreeDeserialize<'de>)),
TreeTrait::Any => (self.deny.ref_any.is_none() || self.deny.mut_any.is_none())
.then_some(parse_quote!(::miniconf::TreeAny)),
};
bound.map(|bound| {
}
.map(|bound: syn::TraitBound| {
let ty = self.typ();
quote_spanned!(self.span()=> #ty: #bound,)
})
Expand Down
36 changes: 19 additions & 17 deletions miniconf_mqtt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,21 +527,18 @@ where
Traversal::TooShort(_depth),
)) => {
// Internal node: Dump or List
(state.state() == &sm::States::Single)
.then_some(())
.ok_or("Pending multipart response")
.and_then(|()| Multipart::try_from(properties))
.map_or_else(
|err| {
Self::respond(err, ResponseCode::Error, properties, client)
.ok();
},
|m| {
(state.state() != &sm::States::Single)
.then_some("Pending multipart response")
.or(Multipart::try_from(properties)
.map(|m| {
*pending = m.root(path).unwrap(); // Note(unwrap) checked that it's TooShort but valid leaf
state.process_event(sm::Events::Multipart).unwrap();
// Responses come through iter_list/iter_dump
},
);
})
.err())
.map(|msg| {
Self::respond(msg, ResponseCode::Error, properties, client).ok()
});
}
minimq::PubError::Serialization(err) => {
Self::respond(err, ResponseCode::Error, properties, client).ok();
Expand All @@ -557,11 +554,16 @@ where
State::Unchanged
} else {
// Set
json::set_by_key(settings, path, payload)
.map_err(|err| Self::respond(err, ResponseCode::Error, properties, client).ok())
.map(|_depth| Self::respond("OK", ResponseCode::Ok, properties, client).ok())
.is_ok()
.into()
match json::set_by_key(settings, path, payload) {
Err(err) => {
Self::respond(err, ResponseCode::Error, properties, client).ok();
State::Unchanged
}
Ok(_depth) => {
Self::respond("OK", ResponseCode::Ok, properties, client).ok();
State::Changed
}
}
}
})
.map(Option::unwrap_or_default)
Expand Down

0 comments on commit e61e257

Please sign in to comment.