Kriskras99 commented on code in PR #569:
URL: https://github.com/apache/avro-rs/pull/569#discussion_r3493041644


##########
avro_derive/src/enums/record_tag_content.rs:
##########
@@ -0,0 +1,161 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::attributes::{NamedTypeOptions, Repr, VariantOptions};
+use crate::case::RenameRule;
+use crate::enums::variant_to_schema_expr;
+use crate::implementation::Implementation;
+use crate::utils::{aliases, json_value_expr, name_expr, preserve_optional, 
rename_ident};
+use proc_macro2::{Ident, Span};
+use quote::quote;
+use std::collections::HashSet;
+use syn::spanned::Spanned;
+use syn::{DataEnum, Generics};
+
+pub fn to_implementation(
+    input_span: Span,
+    ident: Ident,
+    generics: Generics,
+    container_attrs: NamedTypeOptions,
+    data: DataEnum,
+) -> Result<Implementation, Vec<syn::Error>> {
+    let Some(Repr::RecordTagContent { tag, content }) = container_attrs.repr 
else {
+        unreachable!()
+    };
+    let mut errors = Vec::new();
+    let mut symbols = Vec::new();
+    let mut variant_exprs = Vec::new();
+
+    for variant in data.variants {
+        let variant_attrs = VariantOptions::new(&variant.attrs, 
variant.span())?;
+
+        if variant_attrs.skip {
+            continue;
+        }
+
+        let name = rename_ident(
+            &variant.ident,
+            variant_attrs.rename.clone(),
+            container_attrs.rename_all,
+            RenameRule::apply_to_variant,
+        );
+
+        match variant_to_schema_expr(
+            variant,
+            variant_attrs,
+            container_attrs.rename_all,
+            container_attrs.rename_all_fields,
+            true,
+            true,
+            |_| Ok(()),
+        ) {
+            Ok(expr) => variant_exprs.push(expr),
+            Err(errs) => errors.extend(errs),
+        }
+
+        symbols.push(name);

Review Comment:
   I don't think it matters, any errors thrown inside `variant_to_schema_expr` 
are related to creating the schema itself. If the symbol is a duplicate then we 
still want to inform the user even if one of the schema expressions failed to 
create.
   I've moved the statement up directly after we create the `name` so they are 
together



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to