Skip to content

Conversation

@dhardy
Copy link
Member

@dhardy dhardy commented Dec 10, 2025

  • Added a CHANGELOG.md entry

Summary

Remove BlockRng::index field by storing it in the buffer.

Add method BlockRng::remaining_results and constructor reconstruct to allow external serialization.

Details

This replaces #30. Unlike in #24, I decided to let remaining_results return a (variable length) slice, but with an upper bound on its length so that it is possible to serialize this as a fixed-length array (left to the serialization implementer; with text reprs like JSON a variable-length array is probably preferred).

Removes the index field as an optimization, as in #24.

Comment on lines -191 to 223
/// Generate a new set of results immediately, setting the index to the
/// given value.
/// Updates the index and buffer contents
///
/// If `index == 0`, this marks the buffer as "empty", causing generation on
/// next use.
///
/// If `index > 0`, this generates a new block immediately then sets the
/// index.
#[inline]
pub fn generate_and_set(&mut self, index: usize) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a change of behaviour, but should only be observable if the caller uses generate_and_set(0) without immediately generating any output and cares that Generator::generate was not called. As such, I didn't bother mentioning this in the CHANGELOG.

I considered renaming it but decided not to.

@dhardy dhardy merged commit 77770a4 into master Dec 10, 2025
13 checks passed
@dhardy dhardy deleted the block-buffer-internals branch December 10, 2025 16:03
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