Skip to content

Modernize core::extfmt::ct #4372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from Jan 7, 2013
Merged

Modernize core::extfmt::ct #4372

merged 12 commits into from Jan 7, 2013

Conversation

ghost
Copy link

@ghost ghost commented Jan 7, 2013

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<T> { 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.

@catamorphism
Copy link
Contributor

I'll take a look at this!

@ghost ghost assigned catamorphism Jan 7, 2013
catamorphism added a commit that referenced this pull request Jan 7, 2013
Modernize core::extfmt::ct
@catamorphism catamorphism merged commit aed94a3 into rust-lang:incoming Jan 7, 2013
@catamorphism
Copy link
Contributor

Great cleanup work, thanks for this!

@ghost ghost deleted the fmt2 branch January 7, 2013 22:41
@ghost ghost unassigned catamorphism Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants