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

mutateEach(:) #313

Merged
merged 3 commits into from
May 13, 2024
Merged

mutateEach(:) #313

merged 3 commits into from
May 13, 2024

Conversation

tonikocjan
Copy link
Contributor

Implemented a mutable version of forEach.

Instead of writing smth like

for idx in 0..<c.count {
  c[idx].mutate()
}

, you can use mutateEach:

c.mutateEach { $0.mutate() }

@tonikocjan tonikocjan requested a review from a team April 3, 2024 11:16
@tonikocjan tonikocjan changed the title Mutate each mutateEach(:) Apr 3, 2024
Copy link
Collaborator

@borut-t borut-t left a comment

Choose a reason for hiding this comment

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

👌

Comment on lines 48 to 56
mutating func mutateEach(_ f: (inout Element) throws -> Void) rethrows {
var i = startIndex
while i != endIndex {
try f(&self[i])
formIndex(after: &i)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we prefer param names length >= 2?

@tonikocjan tonikocjan force-pushed the feature/collection-mutate-each branch from f212240 to c4b8d0d Compare April 18, 2024 08:31
Base automatically changed from chore/count to fix/async-throttle-sequence2 May 13, 2024 10:16
@tonikocjan tonikocjan force-pushed the fix/async-throttle-sequence2 branch from e7f93f0 to 368cb26 Compare May 13, 2024 10:18
Base automatically changed from fix/async-throttle-sequence2 to develop May 13, 2024 10:31
@tonikocjan tonikocjan force-pushed the feature/collection-mutate-each branch from c4b8d0d to e578dec Compare May 13, 2024 10:36
@tonikocjan tonikocjan force-pushed the feature/collection-mutate-each branch from e578dec to 8f46857 Compare May 13, 2024 10:47
@tonikocjan tonikocjan merged commit b93005a into develop May 13, 2024
2 checks passed
@tonikocjan tonikocjan deleted the feature/collection-mutate-each branch May 13, 2024 13:21
borut-t pushed a commit that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants