Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a Result from Taffy::remove #106

Merged

Conversation

sixfold-origami
Copy link
Collaborator

@sixfold-origami sixfold-origami commented Jun 9, 2022

Objective

Fixes: #102

Returning a Result here has two nice benefits for users:

  • The API is more consistent with similar methods like Sprawl::remove_child and Sprawl::remove_child_at_index
  • The end user can verify that the removal actually removed something, and what that something actually was

Context

The original issue suggests using an Option<Id> for this, but I decided to use Result<usize, Error> for three reasons:

  • Better consistency with other API methods (see above)
  • Sprawl::find_node returns a Result, and it would be good to propagate that error up.
  • NodeId is only used internally, so the public API should use the underlying usize

I also updated the docstring, as returning a usize without any additional context could be confusing.

Feedback wanted

This is a breaking change. I understand I'm supposed to update RELEASES.md, but the exact details on this aren't super clear. Is what I wrote acceptable? Resolved

@alice-i-cecile alice-i-cecile added usability Make the library more comfortable to use breaking-change A change that breaks our public interface blocked Cannot be advanced until something else changes labels Jun 9, 2022
RELEASES.md Outdated Show resolved Hide resolved
src/node.rs Outdated Show resolved Hide resolved
@sixfold-origami sixfold-origami marked this pull request as ready for review June 9, 2022 00:57
@sixfold-origami sixfold-origami changed the title Return a result from Sprawl::remove Return a Result from Sprawl::remove Jun 9, 2022
Copy link
Collaborator

@Weibye Weibye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and makes sense :)

@Weibye
Copy link
Collaborator

Weibye commented Jun 10, 2022

PR title should be updated to "Return a Result from Taffy::remove"

@alice-i-cecile alice-i-cecile changed the title Return a Result from Sprawl::remove Return a Result from Taffy::remove Jun 10, 2022
tests/node.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile enabled auto-merge (squash) June 10, 2022 20:49
@alice-i-cecile
Copy link
Collaborator

@sixfold I broke the merge, sorry! Are you able to fix this?

@sixfold-origami
Copy link
Collaborator Author

@sixfold I broke the merge, sorry! Are you able to fix this?

Probably. I'll take a look.

auto-merge was automatically disabled June 11, 2022 13:20

Head branch was pushed to by a user without write access

@sixfold-origami
Copy link
Collaborator Author

Should be all fixed now :)

@alice-i-cecile alice-i-cecile merged commit d58313d into DioxusLabs:main Jun 11, 2022
jkelleyrtp pushed a commit that referenced this pull request Oct 10, 2022
* Return a result from Sprawl::remove

* Update `RELEASES.md`

* Fix clippy error, fix compiler warnings

Deciding to unwrap in the tests, so that the tests fail if the remove fails.

* Run cargo fmt

* Move release note to new "0.2.0" section

* Add blank lines to satiate the Markdown Lint gods

* Remove pointless let _ = call

* Fix merge error

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Cannot be advanced until something else changes breaking-change A change that breaks our public interface usability Make the library more comfortable to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sprawl::remove should return an Option<Id>
3 participants