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.
BorrowedCursor::advance
1 parent 3b96c9b commit b0152aaCopy full SHA for b0152aa
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