Skip to content

TryPush trait to enable non-reallocating pushes#54

Open
antiguru wants to merge 5 commits intomainfrom
try_push
Open

TryPush trait to enable non-reallocating pushes#54
antiguru wants to merge 5 commits intomainfrom
try_push

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 <antiguru@gmail.com>
Signed-off-by: Moritz Hoffmann <antiguru@gmail.com>
Signed-off-by: Moritz Hoffmann <antiguru@gmail.com>
Signed-off-by: Moritz Hoffmann <antiguru@gmail.com>
Signed-off-by: Moritz Hoffmann <antiguru@gmail.com>
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