You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "martin-g (via GitHub)" <gi...@apache.org> on 2023/08/10 06:37:23 UTC

[GitHub] [avro] martin-g commented on a diff in pull request #2433: AVRO-3827: [Rust] Disallow duplicate field names

martin-g commented on code in PR #2433:
URL: https://github.com/apache/avro/pull/2433#discussion_r1289625290


##########
lang/rust/avro/src/schema.rs:
##########
@@ -1440,7 +1440,12 @@ impl Parser {
                     .collect::<Result<_, _>>()
             })?;
 
+        let mut existing_fields: HashSet<&String> = HashSet::with_capacity(fields.len());
         for field in &fields {
+            if existing_fields.contains(&field.name) {
+                return Err(Error::FieldNameDuplicate(field.name.clone()));
+            }
+            existing_fields.insert(&field.name);

Review Comment:
   Do we need the new data structure ?
   We can use the returned value of https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.insert to decide whether to return an error or not.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org