Skip to content

Adopt the regex! macro - #166

Merged
danieldickison merged 1 commit into
mainfrom
codex/adopt-regex-macro
Jul 19, 2026
Merged

Adopt the regex! macro#166
danieldickison merged 1 commit into
mainfrom
codex/adopt-regex-macro

Conversation

@danieldickison

Copy link
Copy Markdown
Owner

Summary

  • replace all three reusable Rust regex singletons with regex!
  • expose the player-name regex through a shared accessor and use Regex::as_str() for the HTML validation pattern
  • replace the SumoDB builder option with the equivalent inline (?s) flag
  • remove all regex-related LazyLock and RegexBuilder boilerplate

This PR is stacked on #164 because regex! was introduced in regex 1.13.0.

Two unrelated LazyLock uses remain for the JST offset and SUMO_API_DRY_RUN; LazyLock is provided by the standard library rather than a Cargo dependency.

Validation

  • cargo test --locked
  • cargo clippy --locked --all-targets -- -D warnings

Base automatically changed from dependabot/cargo/rust-minor-bfa3495637 to main July 16, 2026 03:48
@danieldickison
danieldickison requested a review from Copilot July 16, 2026 03:48
@danieldickison
danieldickison marked this pull request as ready for review July 16, 2026 03:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors reusable Rust regex singletons to use the new regex! macro (regex 1.13.0), reducing LazyLock/RegexBuilder boilerplate while keeping the existing validation and parsing behavior.

Changes:

  • Replaced regex LazyLock singletons with regex! call sites for player-name validation, SQLite trace normalization, and SumoDB HTML parsing.
  • Exposed the player-name regex via a shared accessor and used Regex::as_str() in the settings form’s HTML pattern.
  • Replaced the SumoDB builder option (dot_matches_new_line) with the inline (?s) flag.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
templates/settings.html Uses the shared Rust player-name regex pattern string for HTML input validation.
src/handlers/admin.rs Switches the SumoDB parsing regex from LazyLock/RegexBuilder to an inline regex! call with (?s).
src/data/player.rs Replaces the player-name regex singleton with name_regex() backed by regex! and updates validation to use it.
src/data/mod.rs Replaces debug SQLite trace whitespace-normalization singleton with an inline regex! call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danieldickison
danieldickison merged commit c6c0e64 into main Jul 19, 2026
5 checks passed
@danieldickison
danieldickison deleted the codex/adopt-regex-macro branch July 19, 2026 01:26
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