3

In the definition of polars SerWriter trait:

pub trait SerWriter<W>
where
    W: Write,
{
    fn new(writer: W) -> Self;
    fn finish(&mut self, df: &mut DataFrame) -> Result<(), PolarsError>;
}

The finish method require a mut reference. Since the method is supposed to write a DataFrame to a buffer it should leave the underlying data unchanged. This makes it harder to interact with other serialization frameworks such as serde which in the serialize method of its Serialize trait requires an immutable reference. Is there any other solution than to call .clone() in case one has just a regular reference?

Bartek
  • 155
  • 1
  • 4

0 Answers0