martin-g commented on code in PR #328:
URL: https://github.com/apache/avro-rs/pull/328#discussion_r2479467943


##########
avro/src/writer.rs:
##########
@@ -366,9 +366,10 @@ impl<'a, W: Write> Writer<'a, W> {
         let mut this = ManuallyDrop::new(self);
 
         // Extract every member that is not Copy and therefore should be 
dropped
-        let _resolved_schema = std::mem::take(&mut this.resolved_schema);
         let _buffer = std::mem::take(&mut this.buffer);
         let _user_metadata = std::mem::take(&mut this.user_metadata);
+        // SAFETY: resolved schema is not accessed after this and won't be 
dropped because of ManuallyDrop
+        unsafe { std::ptr::drop_in_place(&mut this.resolved_schema) };

Review Comment:
   Why this does not use `std::mem::take()` as the others above ? 



##########
avro/src/writer.rs:
##########
@@ -366,9 +366,10 @@ impl<'a, W: Write> Writer<'a, W> {
         let mut this = ManuallyDrop::new(self);
 
         // Extract every member that is not Copy and therefore should be 
dropped
-        let _resolved_schema = std::mem::take(&mut this.resolved_schema);
         let _buffer = std::mem::take(&mut this.buffer);
         let _user_metadata = std::mem::take(&mut this.user_metadata);
+        // SAFETY: resolved schema is not accessed after this and won't be 
dropped because of ManuallyDrop
+        unsafe { std::ptr::drop_in_place(&mut this.resolved_schema) };

Review Comment:
   Did I ask before why the `codec` is not dropped here ? I don't remember now



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