-
Notifications
You must be signed in to change notification settings - Fork 53
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
Panic on semantic error, rather than returning error? #29
Labels
Comments
Issue-Label Bot is automatically applying the label Links: app homepage, dashboard and code for this bot. |
Hey @lo48576 👋 thanks for the issue report. Do you mind proposing a change as PR? :) |
I'll try to write a PR. |
lo48576
added a commit
to lo48576/indextree
that referenced
this issue
Jul 31, 2019
When the functions noticed inconsistent data, they are broken in unexpected way and nothing meaningful can be done anymore. In such cases, the library should panic and all following operations should be cancelled. Additionally, now `NodeId::prepend()` works same as `append()` when the parent node has no children. (Previously, it is not possible to `prepend()` to the parent node which has no children yet.) By this change, their behavior become symmetric and `prepend()` requires fewer preconditions. Fixed saschagrunert#29 and saschagrunert#30.
lo48576
added a commit
to lo48576/indextree
that referenced
this issue
Jul 31, 2019
When the functions noticed inconsistent data, they are broken in unexpected way and nothing meaningful can be done anymore. In such cases, the library should panic and all following operations should be cancelled. Additionally, now `NodeId::prepend()` works same as `append()` when the parent node has no children. (Previously, it is not possible to `prepend()` to the parent node which has no children yet.) By this change, their behavior become symmetric and `prepend()` requires fewer preconditions. Fixes saschagrunert#29 and saschagrunert#30.
lo48576
added a commit
to lo48576/indextree
that referenced
this issue
Jul 31, 2019
When the functions noticed inconsistent data, they are broken in unexpected way and nothing meaningful can be done anymore. In such cases, the library should panic and all following operations should be cancelled. Additionally, now `NodeId::prepend()` works same as `append()` when the parent node has no children. (Previously, it is not possible to `prepend()` to the parent node which has no children yet.) By this change, their behavior become symmetric and `prepend()` requires fewer preconditions. Fixes saschagrunert#29 and saschagrunert#30.
saschagrunert
pushed a commit
that referenced
this issue
Jul 31, 2019
When the functions noticed inconsistent data, they are broken in unexpected way and nothing meaningful can be done anymore. In such cases, the library should panic and all following operations should be cancelled. Additionally, now `NodeId::prepend()` works same as `append()` when the parent node has no children. (Previously, it is not possible to `prepend()` to the parent node which has no children yet.) By this change, their behavior become symmetric and `prepend()` requires fewer preconditions. Fixes #29 and #30.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems
indextree
avoids panicking, even if there are semantic error (caused by broken inconsistent data).For example:
indextree/src/lib.rs
Lines 460 to 471 in 0e51295
In this code, if
self_borrow.last_child
wasNone
,self_borrow.first_child
should be alsoNone
, ifindextree
is working correctly.If it is not, then the data can (and may) have been broken in unexpected way, and it seems meaningless to do more operation on that broken data.
Additionally, results are returned as
Fallible<_>
and it does type erasure, so users might easily miss such semantic bug.I think semantic errors should be caught by panicking (typically
.expect()
onResult
andOption
) and assert macros.The text was updated successfully, but these errors were encountered: