Skip to content

feat: trait rework#9

Merged
bbaldino merged 5 commits into
masterfrom
trait_rework
May 1, 2025
Merged

feat: trait rework#9
bbaldino merged 5 commits into
masterfrom
trait_rework

Conversation

@bbaldino
Copy link
Copy Markdown
Owner

@bbaldino bbaldino commented May 1, 2025

This tweaks the ParselyRead and ParselyWrite traits yet again in order to allow manual implementations of them using a custom type. This is useful for some types which want to be able to operate on Bits directly instead of some generic BitBuf or if some other buffer type in general wants to be used.

i found i had scenarios where i wanted to be able to use the
ParselyRead/ParselyWrite traits but not necessarily with
`BitBuf`/`BitBufMut`, so I wanted to be able to use them with different
buffer types.  In order to do that, I needed to move the buffer back to
a generic on the ParselyWrite trait.  Previously this was an issue with
how I was coercing the result of expressions in attributes: I needed
know generics there for it to work reasonably as a trait bound.  But I
found putting the buffer there should work alright: it makes sense to
require we can get a type that can be written to the current buffer.
@bbaldino bbaldino requested a review from Copilot May 1, 2025 18:22
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 reworks the ParselyRead and ParselyWrite traits to enable manual implementations using custom types and improves type inference by removing redundant generic placeholders. Key changes include:

  • Removing the redundant "_" generic type argument from read and write invocation calls in tests.
  • Updating trait definitions and implementations in both the core library and code-generation modules to include the buffer type as a generic parameter.
  • Adjusting padding-handling code in the generated implementations for read and write.

Reviewed Changes

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

Show a summary per file
File Description
tests/ui/pass/*.rs Updated calls to Foo::read/Foo::write to remove the redundant generic parameter.
tests/expand/*.expanded.rs Modified code generation for mapping, assertion, and alignment to reflect the new trait design.
impl/src/parsely_read.rs, parsely_write.rs Updated trait definitions and implementations to include an explicit BitBuf/BitsMut generic parameter.
impl/src/code_gen/gen_read.rs, gen_write.rs Adjusted code generation for read/write impls to adopt the new trait structure and padding handling.
impl/src/error.rs Updated the conversion utility traits to align with the removal of the "read" suffix in method calls.
impl/Cargo.toml Bumped the bits-io dependency version to support the changes.
Notes.md Expanded documentation clarifying support for custom types in ParselyRead/ParselyWrite.

@bbaldino bbaldino merged commit 35a5981 into master May 1, 2025
1 check passed
@bbaldino bbaldino deleted the trait_rework branch May 1, 2025 18:27
@github-actions github-actions Bot mentioned this pull request Apr 30, 2025
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