Skip to content

feat: add infallible first-last accessor methods#7

Merged
hubcycle merged 1 commit intomainfrom
feature/6-infalliable-first-last
Jul 18, 2025
Merged

feat: add infallible first-last accessor methods#7
hubcycle merged 1 commit intomainfrom
feature/6-infalliable-first-last

Conversation

@hubcycle
Copy link
Copy Markdown
Owner

  • provide first(), last(), split_first(), split_last() methods.
  • use unsafe blocks for performance, and throughly document the safety.
  • add tests and miri workflow to ci.

- provide `first()`, `last()`, `split_first()`, `split_last()` methods.
- use unsafe blocks for performance, and throughly document the safety.
- add tests and miri workflow to ci.
@hubcycle hubcycle requested a review from Copilot July 18, 2025 09:49
@hubcycle hubcycle self-assigned this Jul 18, 2025
@hubcycle hubcycle added the enhancement New feature or request label Jul 18, 2025
@hubcycle hubcycle linked an issue Jul 18, 2025 that may be closed by this pull request
Copy link
Copy Markdown

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 PR adds infallible accessor methods to the NonEmptyBz type for retrieving first and last bytes, along with splitting operations. The implementation leverages the non-empty guarantee to use unsafe optimizations while maintaining safety through thorough documentation and Miri testing.

  • Implements first(), last(), split_first(), and split_last() methods with unsafe optimizations
  • Adds comprehensive test coverage using rstest parameterized tests
  • Introduces Miri CI workflow for undefined behavior detection

Reviewed Changes

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

File Description
src/lib.rs Implements the four new accessor methods with unsafe blocks and comprehensive test suite
README.md Documents the safety notice and Miri verification process
Cargo.toml Version bump and adds rstest dev dependency
.github/workflows/miri.yml New CI workflow for Miri undefined behavior testing

@hubcycle hubcycle changed the title feat: add infalliable first-last accessor methods feat: add infallible first-last accessor methods Jul 18, 2025
@hubcycle hubcycle merged commit f7a5cad into main Jul 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

infallible accessor methods to first and last byte

2 participants