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

The scalar_at and scalar_at_unchecked API is easy to misuse #687

Open
danking opened this issue Aug 27, 2024 · 0 comments
Open

The scalar_at and scalar_at_unchecked API is easy to misuse #687

danking opened this issue Aug 27, 2024 · 0 comments
Assignees

Comments

@danking
Copy link
Member

danking commented Aug 27, 2024

There are two core issues:

  1. scalar_at / scalar_at_unchecked can be called at least three ways: scalar_at(array, index), encoded_array.scalar_at(index), and array.with_dyn(|a| a.scalar_at(index). The semantics of the latter two differ from that of the first.

  2. There are four possible combinations of bounds-checking and validity-checking but for any given pair of scalar_at / scalar_at_unchecked, only two versions are available. Moreover, no option performs validity checks without bounds checks.

    function bounds checked validity checked
    scalar_at(array, index) yes yes
    scalar_at_unchecked(array, index) no no
    encoded_array.scalar(index) yes no
    encoded_array.scalar_at_unchecked(index) no no

    NB: with_dyn has the same semantics as the second pair.

@danking danking self-assigned this Aug 27, 2024
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