Skip to content
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

Bring net/parser.rs up to modern up to date with modern rust patterns #72369

Merged
merged 1 commit into from
Jul 1, 2020

Commits on Jun 30, 2020

  1. Bring net/parser.rs up to modern up to date with modern rust patterns

    Made the following changes throughout the IP address parser:
    - Replaced all uses of `is_some()` / `is_none()` with `?`.
    - "Upgraded" loops wherever possible; ie, replace `while` with `for`, etc.
        - Removed all cases of manual index tracking / incrementing.
    - Renamed several single-character variables with more expressive names.
    - Replaced several manual control flow segments with equivalent adapters (such as `Option::filter`).
    - Removed `read_seq_3`; replaced with simple sequences of `?`.
    - Parser now reslices its state when consuming, rather than carrying a separate state and index variable.
    - `read_digit` now uses `char::to_digit`.
    - Removed unnecessary casts back and forth between u8 and u32
    - Added comments throughout, especially in the complex IPv6 parsing logic.
    - Added comprehensive local unit tests for the parser to validate these changes.
    Lucretiel authored and dtolnay committed Jun 30, 2020
    Configuration menu
    Copy the full SHA
    3ab7ae3 View commit details
    Browse the repository at this point in the history