Skip to main content

try_match

Function try_match 

Source
fn try_match(bytes: &[u8], i: usize) -> Option<(usize, char)>
Expand description

Attempt to match a table entry starting at bytes[i]. Longest-first (the spec rule): try 3-byte ligatures before 2-byte digraphs.

  • 3-byte path: a 4-arm match against the four ligatures (ae&, AE&, oe&, OE&). match_ligature lowers to a tight jump-table-or-direct-compares form.
  • 2-byte path: O(1) lookup in ACCENT_DIGRAPHS, a phf::Map built at compile time over all 110 spec digraph entries.

Returns (consumed_bytes, replacement_char) on match.