MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / read_u16

Function read_u16

src/phar.rs:175–183  ·  view source on GitHub ↗

Read a little-endian `u16` from `data` at `*cursor`, advancing the cursor.

(data: &[u8], cursor: &mut usize)

Source from the content-addressed store, hash-verified

173
174/// Read a little-endian `u16` from `data` at `*cursor`, advancing the cursor.
175fn read_u16(data: &[u8], cursor: &mut usize) -> Option<u16> {
176 let end = *cursor + 2;
177 if end > data.len() {
178 return None;
179 }
180 let bytes: [u8; 2] = data[*cursor..end].try_into().ok()?;
181 *cursor = end;
182 Some(u16::from_le_bytes(bytes))
183}
184
185// ─── Tests ──────────────────────────────────────────────────────────────────
186

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected