-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(signals): add WritableResultExt trait#5338
Open
costajohnt wants to merge 2 commits intoDioxusLabs:mainfrom
Open
feat(signals): add WritableResultExt trait#5338costajohnt wants to merge 2 commits intoDioxusLabs:mainfrom
costajohnt wants to merge 2 commits intoDioxusLabs:mainfrom
Conversation
Summary
Adds WritableResultExt trait for Writable, mirroring the existing ReadableResultExt on the read side. This provides mutable access to signal values holding Result without needing an intermediate binding.
Methods
as_mut()-- returnsResult, giving mutable access to whichever variant the Result holds, WritableRef > unwrap_mut()-- returnsWritableRef, panicking if the Result isErr
Pattern
Follows the same extension trait pattern used by WritableOptionExt and ReadableResultExt:
- Blanket impl over all
W: Writable> - Uses
WriteLock::map/WriteLock::filter_mapfor mapped mutable references #[track_caller]on all methods for better panic diagnostics
Closes #5293
Add WritableResultExt mirroring the existing ReadableResultExt,
providing mutable access to signal values holding Result.
Methods:
- as_mut(): returns Result, WritableRef>
- unwrap_mut(): returns WritableRef, panics if Err
Closes DioxusLabs#5293
providing mutable access to signal values holding Result
Methods:
- as_mut(): returns Result
- unwrap_mut(): returns WritableRef
Closes DioxusLabs#5293
...xt::as_mut
Replace bare .unwrap() calls with .expect() containing a descriptive
message about the failure mode. This gives better diagnostics if the
Result variant changes between the read and write lock acquisitions.
Replace bare .unwrap() calls with .expect() containing a descriptive
message about the failure mode. This gives better diagnostics if the
Result variant changes between the read and write lock acquisitions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.