Skip to content

feat(encoding): add hex package#3625

Open
bobzhang wants to merge 1 commit into
mainfrom
codex/encoding-hex
Open

feat(encoding): add hex package#3625
bobzhang wants to merge 1 commit into
mainfrom
codex/encoding-hex

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

Summary

  • add moonbitlang/core/encoding/hex for in-memory lowercase hexadecimal encoding and decoding
  • add Go-style encoded_len / decoded_len helpers
  • document malformed input behavior and include README examples

Scope

  • intentionally excludes stream encoder/decoder APIs because core does not expose an IO abstraction here
  • keeps the first PR focused on deterministic in-memory operations

Validation

  • moon check
  • moon test encoding/hex
  • moon test

Copilot AI review requested due to automatic review settings May 24, 2026 14:06
Copy link
Copy Markdown
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

Adds a new moonbitlang/core/encoding/hex package providing deterministic, in-memory lowercase hexadecimal encoding/decoding utilities, mirroring Go’s encoding/hex API style (including encoded_len/decoded_len) and documenting malformed-input behavior.

Changes:

  • Introduces encode, decode, encoded_len, and decoded_len APIs plus a Malformed error type.
  • Adds comprehensive unit tests for encoding/decoding (including all-byte roundtrip and malformed inputs).
  • Adds package README with runnable examples.

Reviewed changes

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

Show a summary per file
File Description
encoding/hex/README.mbt.md Documents API, malformed behavior, and provides runnable examples.
encoding/hex/pkg.generated.mbti Generated public interface for the new package.
encoding/hex/moon.pkg Declares package imports needed by the implementation/tests.
encoding/hex/encode.mbt Implements lowercase hex encoding and encoded_len.
encoding/hex/encode_test.mbt Tests encoding correctness and encoded_len.
encoding/hex/decode.mbt Implements hex decoding, decoded_len, and Malformed error.
encoding/hex/decode_test.mbt Tests decoding correctness, malformed handling, and Debug output.

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

@coveralls
Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 4482

Coverage increased (+0.008%) to 94.097%

Details

  • Coverage increased (+0.008%) from the base build.
  • Patch coverage: 21 of 21 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15873
Covered Lines: 14936
Line Coverage: 94.1%
Coverage Strength: 207071.71 hits per line

💛 - Coveralls

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.

3 participants