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

feat: impl Show for Failure #1364

Merged
merged 7 commits into from
Dec 26, 2024
Merged

feat: impl Show for Failure #1364

merged 7 commits into from
Dec 26, 2024

Conversation

Lampese
Copy link
Collaborator

@Lampese Lampese commented Dec 25, 2024

No description provided.

Copy link

peter-jerry-ye-code-review bot commented Dec 25, 2024

‼️ This code review is generated by a bot. Please verify the content before trusting it.

Here are three observations from the provided git diff output:

  1. Missing Implementation of to_string for Failure:

    • The Show trait implementation for Failure in builtin/show.mbt only includes the output method. However, the Show trait typically requires both output and to_string methods. Without the to_string method, the implementation is incomplete, which could lead to runtime errors or unexpected behavior when converting Failure to a string.
  2. Inconsistent Documentation:

    • The Failure type in builtin/builtin.mbti lacks documentation. Adding a brief comment explaining its purpose and usage would improve code readability and maintainability. For example:
      /// Represents a failure with an associated error message.
      pub(all) type! Failure String
  3. Potential Redundancy in Show Implementation:

    • The Show implementation for Failure in builtin/show.mbt directly outputs a formatted string. If the Failure type is simply a wrapper around String, consider whether this implementation could be simplified or reused from the existing Show implementation for String. For example:
      pub impl Show for Failure with output(self, logger) {
        let Failure(msg) = self
        msg.output(logger)
      }
      This approach avoids duplicating the string formatting logic.

These issues should be addressed to ensure the code is robust, maintainable, and consistent.

@coveralls
Copy link
Collaborator

coveralls commented Dec 25, 2024

Pull Request Test Coverage Report for Build 4329

Details

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 18 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.3%) to 83.033%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtin/show.mbt 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
result/result.mbt 1 75.86%
quickcheck/splitmix/random.mbt 1 71.43%
quickcheck/arbitrary.mbt 3 46.15%
rational/rational.mbt 13 71.21%
Totals Coverage Status
Change from base Build 4325: -0.3%
Covered Lines: 4605
Relevant Lines: 5546

💛 - Coveralls

@Lampese Lampese linked an issue Dec 25, 2024 that may be closed by this pull request
@peter-jerry-ye
Copy link
Collaborator

Should we include the name of the constructor?

builtin/show.mbt Outdated Show resolved Hide resolved
@bobzhang bobzhang enabled auto-merge (rebase) December 26, 2024 00:52
@bobzhang bobzhang merged commit eeff5ad into main Dec 26, 2024
13 checks passed
@bobzhang bobzhang deleted the Show-for-Failure branch December 26, 2024 00:55
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.

impl Show for Failure
4 participants