refactor!: replace Result with panic in stable-structures API#351
refactor!: replace Result with panic in stable-structures API#351
Conversation
|
|
|
|
|
This reverts commit a54abb5.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the public API of stable-structures by removing Result return types and switching to panics on failure. The changes simplify the code by eliminating error handling through Result and updating tests to expect panics for failure cases.
- Public API methods (new, init, push, set, etc.) now panic internally on failure.
- Test cases have been updated to expect panics and no longer unwrap Results.
- Minor import reorderings and cleanup have been applied across affected modules.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/api_confomrance.rs | Updated to remove unwrap handling; also note a filename typo |
| src/vec.rs | Refactored methods to panic on failure instead of returning Result |
| src/min_heap.rs | Similar refactoring applied to heap methods |
| src/log.rs | Refactored initialization to panic on incompatible memory states |
| src/cell.rs | Updated cell creation and update methods to use panic internally |
| Other test files and benchmarks | Updated tests and benchmarks to remove error handling |
Comments suppressed due to low confidence (1)
tests/api_confomrance.rs:1
- The filename 'api_confomrance.rs' appears to contain a typo. Consider renaming it to 'api_conformance.rs' for clarity.
use std::cell::RefCell;
berestovskyy
left a comment
There was a problem hiding this comment.
Looks good, thanks!
[Breaking change] This PR refactors the public API of
stable-structuresto removeResultreturn types and instead panic internally on failure.The change applies to
Vec,MinHeap,Cell, andLog, affecting methods likenew,init,push, etc.These operations are expected to succeed under normal conditions. Returning
Resultforces callers to handle errors that are either:Cellwith a value larger thanu32::MAX)By switching to panics:
.unwrap()or?This is a breaking change and requires updates to any downstream code that previously handled these errors.
Fixes #221