Add fallible try_* API for rust FlatBufferBuilder#8918
Add fallible try_* API for rust FlatBufferBuilder#8918andreiltd wants to merge 2 commits intogoogle:masterfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
hey @andreiltd, this PR looks like a great addition. Could you add some tests for the new functions? |
This is to support error propagation from Allocator trait. The Allocator grow_downwards() method returns Result<(), Self::Error>, but FlatBufferBuilder panics via .expect() when allocation fails instead of propagating the error.
|
Hey @jtdavis777 I've added bunch of integration tests for try api based on previous tests. Thanks for looking at the PR 🙏 |
|
@andreiltd awesome! I think some doc updates would also be good, so that people can see your new feature! |
|
I added a concise section on fallible API to docs in the last commit. |
This is to support error propagation from Allocator trait. The
Allocator::grow_downwards()method returnsResult<(), Self::Error>, but FlatBufferBuilder panics viaexpect()when allocation fails instead of propagating the error. The changes are backward compatible.The main motivation is to support allocators where exhaustion is a recoverable runtime condition e.g., fixed-size memory pools used for backpressure, rather than a fatal system resource error.