Skip to content

Commit

Permalink
Remove unnecessary ok() from openapi-derive (#590)
Browse files Browse the repository at this point in the history
Clippy complains about this in crates using the derive(Union)
  • Loading branch information
amtelekom authored Jun 21, 2023
1 parent 8b55dd1 commit bb33f55
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions poem-openapi-derive/src/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,16 @@ pub(crate) fn generate(args: DeriveInput) -> GeneratorResult<TokenStream> {
} else if !args.one_of {
// any of
from_json.push(quote! {
if let ::std::option::Option::Some(obj) = <#object_ty as #crate_name::types::ParseFromJSON>::parse_from_json(::std::option::Option::Some(::std::clone::Clone::clone(&value)))
.map(Self::#item_ident)
.ok() {
if let ::std::result::Result::Ok(obj) = <#object_ty as #crate_name::types::ParseFromJSON>::parse_from_json(::std::option::Option::Some(::std::clone::Clone::clone(&value)))
.map(Self::#item_ident) {
return ::std::result::Result::Ok(obj);
}
});
} else {
// one of
from_json.push(quote! {
if let ::std::option::Option::Some(obj) = <#object_ty as #crate_name::types::ParseFromJSON>::parse_from_json(::std::option::Option::Some(::std::clone::Clone::clone(&value)))
.map(Self::#item_ident)
.ok() {
if let ::std::result::Result::Ok(obj) = <#object_ty as #crate_name::types::ParseFromJSON>::parse_from_json(::std::option::Option::Some(::std::clone::Clone::clone(&value)))
.map(Self::#item_ident) {
if res_obj.is_some() {
return ::std::result::Result::Err(#crate_name::types::ParseError::expected_type(value));
}
Expand Down

0 comments on commit bb33f55

Please sign in to comment.