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

Function with contract but not leading to UB, unsafe or not? #21

Closed
leudz opened this issue Nov 9, 2019 · 1 comment
Closed

Function with contract but not leading to UB, unsafe or not? #21

leudz opened this issue Nov 9, 2019 · 1 comment
Labels
question Further information is requested

Comments

@leudz
Copy link
Owner

leudz commented Nov 9, 2019

Entities can safely be deleted by using AllStorages but all storages have to be iterated over and it prevents any parallelization.

One way to get around this issue is to have a function on Entities. To make this function safe a component counter could be added to Entities but it would mean borrowing Entities to add/remove components and impact performance of many operations (add/remove entities and components).
To avoid the api and performance issue, a function can be implemented without counter.

delete_unchecked would rely on the user to remove all components from the entity before calling it. In case this isn't respected the user could access components they didn't removed with a deleted entity.

The question is: should delete_unchecked be unsafe or not?

I'm not the first person struggling with the issue rust-lang/api-guidelines#179 but currently no consensus has been reached.

@leudz leudz added the question Further information is requested label Nov 9, 2019
@leudz leudz mentioned this issue Jan 1, 2020
@leudz
Copy link
Owner Author

leudz commented Jan 4, 2020

Based on this discussion and the ones linked into it, I'm closing this issue with the conclusion that it shouldn't be unsafe but just marked *_unchecked.

If someone has good opposing arguments, I'm open to go back on this decision.

@leudz leudz closed this as completed Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant