We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b14b96c + b0152aa commit 1bd8407Copy full SHA for 1bd8407
core/src/io/borrowed_buf.rs
@@ -281,10 +281,10 @@ impl<'a> BorrowedCursor<'a> {
281
/// Panics if there are less than `n` bytes initialized.
282
#[inline]
283
pub fn advance(&mut self, n: usize) -> &mut Self {
284
- let filled = self.buf.filled.strict_add(n);
285
- assert!(filled <= self.buf.init);
+ // The substraction cannot underflow by invariant of this type.
+ assert!(n <= self.buf.init - self.buf.filled);
286
287
- self.buf.filled = filled;
+ self.buf.filled += n;
288
self
289
}
290
0 commit comments