Kriskras99 commented on code in PR #199:
URL: https://github.com/apache/avro-rs/pull/199#discussion_r2115892399
##########
avro/tests/to_from_avro_datum_schemata.rs:
##########
@@ -110,6 +110,7 @@ fn test_avro_3683_multiple_schemata_writer_reader() ->
TestResult {
let mut writer = Writer::with_schemata(schema_b, schemata.clone(), &mut
output, Codec::Null);
writer.append(record.clone())?;
writer.flush()?;
+ let _ = writer.into_inner()?;
Review Comment:
`output` is giving as a mutable reference to `Writer` resulting in a
`Writer<&mut Vec<u8>`.
Because `Writer` now has a Drop implementation, it lives until the end of
the function and therefore requires the mutable reference to live until the end.
By calling `into_inner()` the mutable reference is "given back" to `output`
and it can be used again.
Looking at it again, I would modifiy the code like this:
```rust
let mut writer = Writer::with_schemata(schema_b, schemata.clone(),
output, Codec::Null);
writer.append(record.clone())?;
writer.flush()?;
let output = writer.into_inner()?;
```
which makes it a lot less magical.
--
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]