Skip to content

builtin: add a rune iterator method to strings, allowing for for i, r in s.runes_iterator() { without first allocating an array for all the runes#24769

Merged
spytheman merged 2 commits into
vlang:masterfrom
spytheman:add_a_rune_iterator_method_to_strings
Jun 21, 2025

Conversation

@spytheman

@spytheman spytheman commented Jun 21, 2025

Copy link
Copy Markdown
Contributor
  • builtin: add a s.runes_iterator() method, allowing for for i, r in s.runes_iterator() { with no allocations
  • fix if_else_return.c.must_have

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-23186

@Delta456

Copy link
Copy Markdown
Member

When to use .runes_iterator() and .runes()?

@spytheman spytheman changed the title add a rune iterator method to strings builtin: add a rune iterator method to strings Jun 21, 2025
@spytheman

spytheman commented Jun 21, 2025

Copy link
Copy Markdown
Contributor Author

When to use .runes_iterator() and .runes()?

If you need to use runes themselves in an array, use .runes() .

The iterator is useful, when you just need to iterate over all runes in a string, applying some computation on each rune in turn, without allocating an array in advance.

@spytheman spytheman changed the title builtin: add a rune iterator method to strings builtin: add a rune iterator method to strings, allowing for for i, r in s.runes_iterator() { without allocating Jun 21, 2025
@spytheman spytheman changed the title builtin: add a rune iterator method to strings, allowing for for i, r in s.runes_iterator() { without allocating builtin: add a rune iterator method to strings, allowing for for i, r in s.runes_iterator() { without first allocating an array for all the runes Jun 21, 2025
@spytheman spytheman merged commit 194db24 into vlang:master Jun 21, 2025
79 checks passed
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