Update FilteredEntityRef/Mut getters to return Result instead of Option
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Currently `FilteredEntityRef` look like this:
```
/// Gets access to the component of type `T` for the current entity.
/// Returns `None` if the entity does not have a component of type `T`.
#[inline]
pub fn get(&self) -> Option<&'_ T>;
```
The docstring is incorrect, you get a `None` if the entity does not have a component of type `T` OR if the FilteredEntityRef does not have the access to read `T`.
The return value of `Option` makes it impossible to distinguish between the two.
I have multiple times been stuck debugging while my entity does not have a given component T only to realize an hour later that my `FilteredEntityRef` does not have the correct access!!
## What solution would you like?
Change the methods to return a Result, where the Errors could be an enum with:
- InsufficientAccess
- ComponentNotFound
Contributor guide
Assessment
This issue has not been assessed yet.