Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is effectively a modernization of the parsing portion of format string handling (i.e.,
core::extfmt::ct
).It contains the following changes:
Conv
is replaced with an otherwise identicalstruct Conv
.parse_*
functions are replaced with instances ofstruct Parsed<T> { val: T, next: uint }
.cmp::Eq
implementation to facilitate simpler test code.parse_*
andpeek_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 tosubstr
and allows any unknown type specifier character to be printed in its entirety.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.