Skip to content
Myr

Omit missing content match if not needed

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 9476838 · Browse files · 1 file+15 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−11 removed

  • other:+15 added−11 removed

1 file+15 added−11 removed

modified:serde_derive/src/de.rs+15 added-11 removed
1375 unmodified lines
1376 content: #content,1377 }1378 };13791380 let mut missing_content = quote! {1381 _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content))1382 };1383 let mut missing_content_fallthrough = quote!();1381 let missing_content_arms = variants1384 let mut missing_content_arms = variants1385 .iter()1386 .enumerate()1387 .filter(|&(_, variant)| !variant.attrs.skip_deserializing())1388 .filter_map(|(i, variant)| {
11 unmodified lines
1400 #func(#content).map(#this::#variant_ident)1401 }1402 }1403 _ => {1401 missing_content_fallthrough = quote! {1402 _ => _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content))1403 };1404 missing_content_fallthrough = quote!(_ => #missing_content);1405 return None;1406 }1407 };1408 Some(quote! {1409 __Field::#variant_index => #arm,1410 })1411 })1412 .peekable();1410 });1411 let missing_content = quote! {1412 match __field {1413 #(#missing_content_arms)*1414 #missing_content_fallthrough1415 }1416 };1413 if missing_content_arms.peek().is_some() {1414 missing_content = quote! {1415 match __field {1416 #(#missing_content_arms)*1417 #missing_content_fallthrough1418 }1419 };1420 }14211422 // Advance the map by one key, returning early in case of error.1423 let next_key = quote! {1424 try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content))
1625 unmodified lines