Don't return TaffyResult
when Taffy
methods can't fail.
#520
+30,198
−36,816
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.
Fixes: #519.
Affected methods:
new_leaf
,compute_layout
,new_leaf_with_measure
,new_with_children
,remove
,set_measure
,add_child
,set_children
,child_count
,children
,layout
,set_style
,style
,mark_dirty
,dirty
.TODO:
Reduce implicit panicking possibilities.(See: #520 (comment))cargo gentest
RELEASES.md
Feedback wanted
As commented by @nicoburns: Many of the methods can still panic due to the frequent use of direct array indexing. But this shouldn't really be an issue since the keys themselves can't be created without them being registered by the
Taffy
instance, and removal takes ownership of theNodeId
s. But this can unfortunately easily be bypassed by cloning them, or by creating them it from anotherTaffy
instance.So rather than creating checked/unchecked method equivalents, I would suggest removing these runtime panic possibilities by continuing to leverage Rust's build in memory safety and module scoping rules. This means passing borrowed
NodeId
s to methods that don't mutate any values, and removing theNodeId
'sClone
implementation etc.