Skip to content

Replace inner node empty constructor with builder#72

Merged
declanvk merged 2 commits into
mainfrom
random-improvements
May 4, 2026
Merged

Replace inner node empty constructor with builder#72
declanvk merged 2 commits into
mainfrom
random-improvements

Conversation

@declanvk
Copy link
Copy Markdown
Owner

@declanvk declanvk commented May 4, 2026

  • Replace inner node empty constructor with builder
  • Update changelog for recent range bug

declanvk added 2 commits May 4, 2026 16:26
**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.
@declanvk declanvk merged commit 9b221e2 into main May 4, 2026
4 checks passed
@declanvk declanvk deleted the random-improvements branch May 4, 2026 23:47
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.

1 participant