refactor(ring): stop exposing Ring internals
#1491
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR hides the internals of the
Ring<T>type and reworks its API. Direct access to the internalVecDeque<T>is removed, so interaction withRingnow happens only through its methods, making it easier and safer to use.All lock-respecting insert/remove/swap logic is implemented directly on
Ringand the separateLockableSequencetrait removed.The new API is more ergonomic and expressive for common patterns. As a result, although many new methods were added to
Ringinkomorebi/src/ring.rs, the total code size increased only slightly, since many typical iterator chains are now replaced by single method calls.Motivation
Usability Improvements
Consistent Access: Field and accessor now always return
Ring, eliminating confusion between types (e.g.,&monitor.workspacesvsmonitor.workspaces()).Ergonomic usage: The new API is more ergonomic and expressive for common patterns
Tests
Tested on Windows 11.