Skip to content

Conversation

Boshen
Copy link
Member

@Boshen Boshen commented Sep 30, 2025

Summary

Add const qualifiers to methods that can be evaluated at compile time, enabling their use in const contexts.

Changes

IndexVec

  • new() - const constructor
  • as_vec() - const accessor
  • as_mut_vec() - const mutable accessor

IndexSlice

  • as_raw_slice() - const accessor
  • as_raw_slice_mut() - const mutable accessor
  • as_ptr() - const pointer accessor
  • as_mut_ptr() - const mutable pointer accessor
  • len() - const length
  • is_empty() - const check
  • first() - const first element
  • last() - const last element

Macro-generated index types (define_index_type!)

  • index() - const index getter
  • raw() - const raw value getter
  • from_usize_unchecked() - const unchecked constructor
  • from_raw_unchecked() - const unchecked raw constructor

Macro-generated NonMax index types (define_nonmax_index_type!)

  • from_raw() - const constructor
  • index() - const index getter
  • raw() - const raw value getter
  • from_usize_unchecked() - const unchecked constructor
  • from_raw_unchecked() - const unchecked raw constructor

Testing

All existing tests pass.

🤖 Generated with Claude Code

Boshen and others added 2 commits September 30, 2025 12:52
This commit adds `const` qualifiers to methods that can be evaluated at
compile time, enabling their use in const contexts.

Changes:
- IndexVec: new(), as_vec(), as_mut_vec()
- IndexSlice: as_raw_slice(), as_raw_slice_mut(), as_ptr(), as_mut_ptr(),
  len(), is_empty(), first(), last()
- Macro-generated index types: index(), raw(), from_usize_unchecked(),
  from_raw_unchecked(), from_raw() (NonMaxU32 only)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Makes the following methods const in macro-generated index types:
- new() - const constructor
- from_raw() - const constructor from raw type
- from_usize() - const constructor from usize
- check_index() - const validation (uses panic! instead of __max_check_fail)

This enables index types to be constructed in const contexts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Boshen Boshen merged commit 89ce2a9 into main Sep 30, 2025
4 checks passed
@Boshen Boshen deleted the feat/const-methods branch September 30, 2025 04:58
@Boshen Boshen mentioned this pull request Sep 30, 2025
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.

1 participant