Macro unformat

Source
unformat!() { /* proc-macro */ }
Expand description

Basic implementation of reversing the format! process. Matches a given text against a given pattern, returning any captures.

Rules:

  • Patterns are substring matched.
  • Captures are written as {<index-or-var>?(:<type>)?} in the pattern.
  • Captures are similar to (.*?) in regex, but without backtracking.
  • Sequential captures (e.g. {}{}) are not supported and will return None.

ยงPanics

This function panics if the pattern is invalid. This includes:

  • Consecutive captures.
  • Unmatched } in the pattern.
  • Invalid UTF-8 in capture names.