MCPcopy Create free account
hub / github.com/davidblewett/rure-python / read_varu32

Function read_varu32

regex/src/dfa.rs:1900–1911  ·  view source on GitHub ↗

https://developers.google.com/protocol-buffers/docs/encoding#varints

(data: &[u8])

Source from the content-addressed store, hash-verified

1898
1899/// https://developers.google.com/protocol-buffers/docs/encoding#varints
1900fn read_varu32(data: &[u8]) -> (u32, usize) {
1901 let mut n: u32 = 0;
1902 let mut shift: u32 = 0;
1903 for (i, &b) in data.iter().enumerate() {
1904 if b < 0b1000_0000 {
1905 return (n | ((b as u32) << shift), i + 1);
1906 }
1907 n |= ((b as u32) & 0b0111_1111) << shift;
1908 shift += 7;
1909 }
1910 (0, 0)
1911}
1912
1913#[cfg(test)]
1914mod tests {

Callers 2

read_vari32Function · 0.85
pFunction · 0.85

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected