Function take [src]
Equivalent to peek followed by toss.
The data returned is invalidated by the next call to take, peek,
fill, and functions with those prefixes.
Prototype
pub fn take(r: *Reader, n: usize) Error![]u8
Parameters
r: *Reader
n: usize
Possible Errors
See the Reader
implementation for detailed diagnostics.
Example
test take {
var r: Reader = .fixed("abc");
try testing.expectEqualStrings("ab", try r.take(2));
try testing.expectEqualStrings("c", try r.take(1));
}
Source
pub fn take(r: *Reader, n: usize) Error![]u8 {
const result = try r.peek(n);
r.toss(n);
return result;
}