MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / consume_bytes

Function consume_bytes

src/consume.rs:5–12  ·  view source on GitHub ↗

Attempts to claim `bytes` bytes out of `input`.

(input: &mut &'a [u8], bytes: usize)

Source from the content-addressed store, hash-verified

3
4/// Attempts to claim `bytes` bytes out of `input`.
5pub fn consume_bytes<'a>(input: &mut &'a [u8], bytes: usize) -> Result<&'a [u8]> {
6 if bytes > input.len() {
7 return err("EOF");
8 }
9 let (bytes, remaining) = input.split_at(bytes);
10 *input = remaining;
11 Ok(bytes)
12}
13
14/// Attempts to claim one byte out of `input`.
15pub fn consume_byte(input: &mut &[u8]) -> Result<u8> {

Callers 5

populateMethod · 0.85
unpack_bytes_unsignedFunction · 0.85
unpack_bytes_less_thanFunction · 0.85
unpack_arithmeticFunction · 0.85
consume_byteFunction · 0.85

Calls 2

errFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected