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

Use of Vec<>::remove_item() causes crash despite #![feature] #6

Open
StevenJPx2 opened this issue Nov 2, 2020 · 1 comment
Open

Comments

@StevenJPx2
Copy link

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> terramach/terramach/ui/lib.rs:19:1
   |
19 | #![feature(vec_remove_item)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> terramach/terramach/ui/lib.rs:20:1
   |
20 | #![feature(panic_info_message)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is what I am getting.

Maybe rather than using remove_item(), use a hash map or a handcrafted method?

@StevenJPx2
Copy link
Author

Solution

   --> terramach/terramach/ui/common/tree.rs:144:22
    |
144 |             children.remove_item(&id);
    |                      ^^^^^^^^^^^
    |

If the array is sorted...

children.remove(children.binary_search(&id).expect("Index not found"));

If not,

            for (index, item) in children.clone().iter_mut().enumerate() {
                if item == &id {
                    children.remove(index);
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant