fn validate_self_fields<'a>(fields: impl Iterator<Item = &'a mut FlatSerializeField>) {
    let mut seen_fields = HashSet::new();

    for f in fields {
        if let Some(length_info) = &mut f.length_info {
            if let Err(error) = validate_self_field(&length_info.len_expr, &seen_fields) {
                length_info.len_expr = syn::parse2(error).unwrap()
            }
        }
        seen_fields.insert(f.ident.as_ref().unwrap());
    }
}
/// validate that all references to a field in the struct (e.g. `len` in
/// `[u8; self.len + 1]`) contained in expression refers to already defined
/// fields. Otherwise output a "attempting to use field before definition"
/// compile error. This is used to ensure that wse don't generate structs that
/// are impossible to deserialize because fields are in ambiguous positions such
/// as
/// ```skip
/// struct {
///     variable: [u8; self.len],
///     len: u32,
/// }
/// ```
/// where the position of `len` depends on the value of `len`.
validate that all references to a field in the struct  contained in expression refers to already defined
fields. Otherwise output a "attempting to use field before definition"
compile error.
validate that all references to a field in the struct contained in expression refers to already defined fields . Otherwise output a " attempting to use field before definition " compile error .
fn validate_self_fields<'a>(fields: impl Iterator<Item = &'a mut FlatSerializeField>) {
    let mut seen_fields = HashSet::new();
    for f in fields {
        if let Some(length_info) = &mut f.length_info {
            if let Err(error) = validate_self_field(&length_info.len_expr, &seen_fields) {
                length_info.len_expr = syn::parse2(error).unwrap()
            }
        }
        seen_fields.insert(f.ident.as_ref().unwrap());
    }
}
fn validate_self_fields < ' a > ( fields : impl Iterator < Item = & ' a mut FlatSerializeField > ) { let mut seen_fields = HashSet :: new ( ) ; for f in fields { if let Some ( length_info ) = & mut f . length_info { if let Err ( error ) = validate_self_field ( & length_info . len_expr , & seen_fields ) { length_info . len_expr = syn :: parse2 ( error ) . unwrap ( ) } } seen_fields . insert ( f . ident . as_ref ( ) . unwrap ( ) ) ; } }
validate that all references to a field in the struct (e.g.
validate that all references to a field in the struct ( e . g .
fields
impl Iterator<Item = &'a mut FlatSerializeField>
fields
impl Iterator<Item = &'a mut FlatSerializeField>