Repository: serde-rs/serde
File: serde_derive/src/de.rs (Rust)

Code before:
                    quote! {
                        __Field::#variant_index => _serde::export::Ok(#this::#variant_ident),
                    }
                },
            );
        missing_content = quote! {
            match __field {
                #(#arms)*
                #fallthrough
            }
        };
    }

    /// Advance the map by one key, returning early in case of error.
    let next_key = quote! {
        try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content))
    };

    /// When allowing unknown fields, we want to transparently step through keys we don't care
    /// about until we find `tag`, `content`, or run out of keys.
    let next_relevant_key = if deny_unknown_fields {
        next_key
    } else {
        quote! {
            {
                let mut __rk : Option<_serde::private::de::TagOrContentField> = None;
                while let _serde::export::Some(__k) = #next_key {
                    match __k {
                        _serde::private::de::TagContentOtherField::Other => {
                            try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
                            continue;
                        },
                        _serde::private::de::TagContentOtherField::Tag => {
                            __rk = Some(_serde::private::de::TagOrContentField::Tag);
                            break;
                        }
                        _serde::private::de::TagContentOtherField::Content => {
                            __rk = Some(_serde::private::de::TagOrContentField::Content);
                            break;
                        }
                    }
                }

                __rk
            }
        }
    };

    /// Step through remaining keys, looking for duplicates of previously-seen keys.
    /// When unknown fields are denied, any key that isn't a duplicate will at this
    /// point immediately produce an error.

Review comment (bug):
Please use absolute paths for `Option` and `None` (below as well) to avoid bugs like https://github.com/serde-rs/serde/issues/737#issuecomment-276728419.

Code after:
                    quote! {
                        __Field::#variant_index => _serde::export::Ok(#this::#variant_ident),
                    }
                },
            );
        missing_content = quote! {
            match __field {
                #(#arms)*
                #fallthrough
            }
        };
    }

    /// Advance the map by one key, returning early in case of error.
    let next_key = quote! {
        try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content))
    };

    /// When allowing unknown fields, we want to transparently step through keys we don't care
    /// about until we find `tag`, `content`, or run out of keys.
    let next_relevant_key = if deny_unknown_fields {
        next_key
    } else {
        quote! {
            {
                let mut __rk : _serde::export::Option<_serde::private::de::TagOrContentField> = _serde::export::None;
                while let _serde::export::Some(__k) = #next_key {
                    match __k {
                        _serde::private::de::TagContentOtherField::Other => {
                            try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
                            continue;
                        },
                        _serde::private::de::TagContentOtherField::Tag => {
                            __rk = _serde::export::Some(_serde::private::de::TagOrContentField::Tag);
                            break;
                        }
                        _serde::private::de::TagContentOtherField::Content => {
                            __rk = _serde::export::Some(_serde::private::de::TagOrContentField::Content);
                            break;
                        }
                    }
                }

                __rk
            }
        }
    };

    /// Step through remaining keys, looking for duplicates of previously-seen keys.
    /// When unknown fields are denied, any key that isn't a duplicate will at this
    /// point immediately produce an error.