mozilla/rust — pull request #4372 by apasel422 (2013-01-07 22:30:56+00:00)
Title: Modernize core::extfmt::ct

This is effectively a modernization of the parsing portion of format string
handling (i.e., `core::extfmt::ct`).

It contains the following changes:
* The structural record `Conv` is replaced with an otherwise identical
`struct Conv`.
* The structural records returned from the `parse_*` functions are
replaced with instances of `struct Parsed { val: T, next: uint }`.
* All types have a derived `cmp::Eq` implementation to facilitate
simpler test code.
* The `parse_*` and `peek_num` functions are rewritten to remove
unnecessary moves and copies and to use simplified logic.
* `parse_fmt_string` is rewritten to use two byte indices instead of
string concatenation to build up each string piece.
* `parse_type` now correctly handles multibyte characters; although all
current types are represented by single-byte characters, this prevents
the function from failing through invalid indices passed to `substr`
and allows any unknown type specifier character to be printed in its entirety.
* Most functions now have associated unit tests.
* The module is formatted more consistently.

Note that all function signatures remain the same _modulo_ the removal of
the structural records, so these changes should not affect the code generation or
runtime aspects of formatting.

Feedback is welcome.