about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/io/borrowed_buf.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/io/borrowed_buf.rs b/library/core/src/io/borrowed_buf.rs
index f86abf7f1e9..6bd9c18e00b 100644
--- a/library/core/src/io/borrowed_buf.rs
+++ b/library/core/src/io/borrowed_buf.rs
@@ -281,10 +281,10 @@ impl<'a> BorrowedCursor<'a> {
     /// Panics if there are less than `n` bytes initialized.
     #[inline]
     pub fn advance(&mut self, n: usize) -> &mut Self {
-        let filled = self.buf.filled.strict_add(n);
-        assert!(filled <= self.buf.init);
+        // The substraction cannot underflow by invariant of this type.
+        assert!(n <= self.buf.init - self.buf.filled);
 
-        self.buf.filled = filled;
+        self.buf.filled += n;
         self
     }