Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TryPush trait to enable non-reallocating pushes #54

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

antiguru
Copy link
Owner

@antiguru antiguru commented Jul 3, 2024

Add a TryPush trait that only pushes an item if the region can absorb it without reallocation. This is important for example for pre-sized regions based on some allocation patterns.

The trait offers a try_push function that either returns an index if successful or the item itself if it failed to push it. Additionally, a can_push function takes a reference to the item, and returns a boolean that's true when the region can absorb the item without reallocation.

antiguru added 5 commits July 26, 2024 11:14
Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
Signed-off-by: Moritz Hoffmann <[email protected]>
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