Skip to content

Commit

Permalink
xml: Replace missing field unwrap with error
Browse files Browse the repository at this point in the history
  • Loading branch information
lennart-k committed Jan 15, 2025
1 parent 56e6eed commit 4da975c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/xml/derive/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ impl Field {
(false, true, false) => quote! { builder.#builder_field_ident },
(false, false, true) => quote! { builder.#builder_field_ident },
(false, false, false) => {
quote! { builder.#builder_field_ident.expect("todo: handle missing field") }
let field_ident = self.field_ident().into_token_stream().to_string();
quote! { builder.#builder_field_ident.ok_or(::rustical_xml::XmlDeError::MissingField(#field_ident))? }
}
};
quote! { #target_field_index: #builder_value }
Expand Down

0 comments on commit 4da975c

Please sign in to comment.