From 298463659a38df8d1f17992851cb64c7309600a1 Mon Sep 17 00:00:00 2001 From: Joey Sacchini Date: Thu, 7 Jan 2021 13:57:21 -0500 Subject: fix written data len function --- src/writer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/writer.rs b/src/writer.rs index 8d0fa58..4c0a302 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -607,7 +607,7 @@ struct GrowVecSerializer<'a> { impl<'a> Serializer for GrowVecSerializer<'a> { fn serialize_bytes(&mut self, data: &[u8]) -> SerializeResult { if !self.exceeded_max_size { - let cur_len = self.at - self.offset; + let cur_len = self.written_data_len(); let new_len = cur_len + data.len(); if new_len > self.max_size { self.exceeded_max_size = true; @@ -634,7 +634,7 @@ impl<'a> GrowVecSerializer<'a> { } fn written_data_len(&self) -> usize { - self.at - self.offset + self.at } } -- cgit