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


##########
lang/rust/avro/src/schema.rs:
##########
@@ -1441,6 +1441,9 @@ impl Parser {
             })?;
 
         for field in &fields {
+            if lookup.contains_key(&field.name) {
+                return Err(Error::FieldNameDuplicate(field.name.clone()));
+            }
             lookup.insert(field.name.clone(), field.position);

Review Comment:
   I still think using the returned `Option` from `#insert()` is better than 
doing two lookups.
   ```suggestion
               if let Some(_old) = lookup.insert(field.name.clone(), 
field.position) {
                         return 
Err(Error::FieldNameDuplicate(field.name.clone()));
               }
   ```



-- 
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