Skip to content

Conversation

@rluvaton
Copy link
Member

@rluvaton rluvaton commented Jan 27, 2026

Which issue does this PR close?

None

Rationale for this change

I want to add some optimizations that uses get_unchecked but the safety comment says that we panic on out of range access which might not be the case for get_unchecked.

for example this pr:

What changes are included in this PR?

Update safety note

Are these changes tested?

No

Are there any user-facing changes?

Yes, we no longer guarantee that out of range will panic and instead it can lead to undefined behavior, which the user might not be able to catch

I want to add some optimizations that uses `get_unchecked` but the safety comment says that we panic on out of range access which might not be the case for `get_unchecked`
/// # Safety
///
/// When `options` is not set to check bounds, taking indexes after `len` will panic.
/// When `options` is not set to check bounds, taking indexes after `len` is *undefined behavior*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't just document that something is UB (we would need to mark the code as unsafe as well and need to assure we never pass OOB indices).

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

Successfully merging this pull request may close these issues.

2 participants