Replace inner node empty constructor with builder#72
Merged
Conversation
Owner
declanvk
commented
May 4, 2026
- Replace inner node empty constructor with builder
- Update changelog for recent range bug
**Description** - Move the `from_header` and `from_prefix` inner node constructor functions into a separate crate-private trait. - Add a `::builder` method to the public inner node trait which creates an instance of a type-state inner node builder that only gives access to the contained inner node once it has more than one child. - Update existing ops to use the builder function instead of empty constructor - Delete the empty constructor function - Rework a ton of test code to use the builder **Motivation** For a while there has been an invariant that every inner node has at least one child, but this was not really made explicit anywhere or enforced on construction. This builder type makes it straightforward to construct appropriate inner nodes. There is still a way to bypass it for code inside the crate, where you could write: ```rust N::from_header(Header::from_prefix(&[], 0)) ``` which is a functionally empty. I think this change is still an overall benefit, despite the gap. **Testing Done** Updated a bunch of tests, they all pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.