From eff6700ff4152caf6bd1ecadcb503bf84e69ecd8 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 7 Jan 2024 15:30:53 +0100 Subject: [PATCH] Add back Drop impl for Guard to fix Read::read_to_end --- src/io/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/io/mod.rs b/src/io/mod.rs index ec35323d1d..b4614e3bdb 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -292,6 +292,12 @@ struct Guard<'a> { len: usize, } +impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } + } +} + // A few methods below (read_to_string, read_line) will append data into a // `String` buffer, but we need to be pretty careful when doing this. The // implementation will just call `.as_mut_vec()` and then delegate to a