Skip to content

Add Clone bound to BitIter in Jet::decode()#343

Closed
topologoanatom wants to merge 1 commit intoBlockstreamResearch:masterfrom
topologoanatom:refactor/bit-iter-clone
Closed

Add Clone bound to BitIter in Jet::decode()#343
topologoanatom wants to merge 1 commit intoBlockstreamResearch:masterfrom
topologoanatom:refactor/bit-iter-clone

Conversation

@topologoanatom
Copy link

Fixes #342

}

pub fn decode_expression<'brand, I: Iterator<Item = u8>, J: Jet>(
pub fn decode_expression<'brand, I: Iterator<Item = u8> + Clone, J: Jet>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

In 2db8d12:

This bound is not necessary. Neither are any of the other bounds you added.

Copy link
Author

Choose a reason for hiding this comment

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

Could you elaborate on why the bound is not necessary? Can the related issue be solved without adding the bound, or are you referring to bounds other than the one in the Jet definition? If the latter, I added the minimal number of bounds required for the code to compile.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The function worked without the bound -- adding the bound tightens it, but nothing in the function uses the extra bound. Doing this makes the API less useful, not more useful, because it reduces the number of ways you can call these functions.

The PR description claims that it adds a bound to BitIter but it does not.

Copy link
Author

Choose a reason for hiding this comment

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

but nothing in the function uses the extra bound.

If you're referring to the function in the second code block of the issue description, that's pseudocode to illustrate the motivation. The actual implementation uses clones.

The PR description claims that it adds a bound to BitIter but it does not.

BitIter already derives Clone, so to obtain cloneable iterators, we need to bound the iterator type parameter. Moreover, adding the bound directly to BitIter itself would require a substantial number of changes (possibly all of them) in this codebase, plus changes to the autogenerated jet::init:: files. Sorry if the description was confusing, but this approach seems like the minimal intervention to achieve the issue's goal.

If the existing BitIter API provides a way to rewind steps that I somehow missed, please point it out. Otherwise, is the issue's motivation worthy of restricting bounds?

@apoelstra
Copy link
Collaborator

Please don't submit slop to this repo.

@apoelstra
Copy link
Collaborator

Closing. The Clone impl is already there.

@apoelstra apoelstra closed this Feb 12, 2026
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.

Add Clone bound to BitIter in decode function of Jet trait

2 participants

Comments