Function discardAll [src]
Skips the next n bytes from the stream, advancing the seek position.
Unlike toss which is infallible, in this function n can be any amount.
Returns error.EndOfStream if fewer than n bytes could be discarded.
See also:
toss
discardRemaining
discardShort
discard
Prototype
pub fn discardAll(r: *Reader, n: usize) Error!void
Parameters
r: *Reader
n: usize
Possible Errors
See the Reader
implementation for detailed diagnostics.
Example
test discardAll {
var r: Reader = .fixed("foobar");
try r.discardAll(3);
try testing.expectEqualStrings("bar", try r.take(3));
try r.discardAll(0);
try testing.expectError(error.EndOfStream, r.discardAll(1));
}
Source
pub fn discardAll(r: *Reader, n: usize) Error!void {
if ((try r.discardShort(n)) != n) return error.EndOfStream;
}