Skip to content

Conversation

@wangfu91
Copy link
Owner

@wangfu91 wangfu91 commented Aug 4, 2025

This pull request introduces several changes to improve the consistency and usability of data structures in the codebase by adding new trait derivations. The most notable changes include adding PartialEq, Eq, and Hash implementations to several structs, which enhances their comparability and usability in collections like HashSet or HashMap.

Enhancements to struct trait derivations:

  • src/bounding_box.rs:

    • Added PartialEq to the Point struct, enabling direct equality comparisons between Point instances.
    • Added PartialEq to the BoundingBox struct, allowing equality checks for bounding boxes.
  • src/ocr_options.rs:

    • Added PartialEq, Eq, and Hash to the Resolution struct, making it usable in hashed collections and comparable for equality.
    • Added PartialEq, Eq, and Hash to the OcrOptions struct, improving its usability in contexts requiring equality checks or hashing.
  • src/ocr_word.rs:

    • Added Clone and PartialEq to the OcrWord struct, enabling cloning and equality comparisons for OCR word instances.

Added PartialEq (and Eq, Hash, Clone, Copy where appropriate) to Point, BoundingBox, Resolution, OcrOptions, and OcrWord structs to enable value comparisons and usage in collections. This improves testability and interoperability for OCR-related data types.
@wangfu91 wangfu91 marked this pull request as ready for review August 5, 2025 14:45
Copilot AI review requested due to automatic review settings August 5, 2025 14:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances the interoperability of OCR-related data types by adding essential trait derivations (PartialEq, Eq, Hash, and Clone) to core structs, enabling them to be used in collections and comparison operations.

  • Added equality and hash traits to Resolution and OcrOptions structs for use in hash-based collections
  • Added equality traits to geometric types (Point and BoundingBox) for comparison operations
  • Added Clone and PartialEq traits to OcrWord for enhanced usability

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/ocr_options.rs Added PartialEq, Eq, and Hash to Resolution and OcrOptions structs
src/bounding_box.rs Added PartialEq to Point and BoundingBox structs
src/ocr_word.rs Added Clone and PartialEq to OcrWord struct

Remove the `Copy` trait from the' OcrOptions' struct, as it may contain non-Copy fields in the future.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@wangfu91 wangfu91 self-assigned this Aug 5, 2025
@wangfu91 wangfu91 merged commit 728b0df into master Aug 5, 2025
1 check passed
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.

1 participant