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


##########
avro/src/serde/ser_schema/mod.rs:
##########
@@ -373,52 +378,45 @@ impl<W: Write> ser::SerializeStruct for 
SchemaAwareWriteSerializeStruct<'_, '_,
     where
         T: ?Sized + ser::Serialize,
     {
-        let record_field = self
-            .record_schema
-            .lookup
-            .get(key)
-            .and_then(|idx| self.record_schema.fields.get(*idx));
-
-        match record_field {
-            Some(field) => self.serialize_next_field(field, value).map_err(|e| 
{
-                Details::SerializeRecordFieldWithSchema {
-                    field_name: key.to_string(),
-                    record_schema: Schema::Record(self.record_schema.clone()),
-                    error: Box::new(e),
-                }
-                .into()
-            }),
-            None => Err(Details::FieldName(String::from(key)).into()),
+        if let Some(position) = self.record_schema.lookup.get(key).copied() {
+            let field = &self.record_schema.fields[position];

Review Comment:
   Nope, reverted to use `.get()`.
   
   I do think it would be good to make the `fields` and `lookup` fields of 
`RecordSchema` private and improve the builder.



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