Skip to content

Conversation

illusory0x0
Copy link
Contributor

Iter::singleton(a) + self is more clear than [a].iter() + self and conforms to the conventions of other programming languages.

Copy link

Deprecation message standardization for iterator operations

Category
Maintainability
Code Snippet
#deprecated("Use [a].iter() + self or Iter::singleton(a) + self instead")
#deprecated("Use self + [a].iter() or self + Iter::singleton(a) instead")
Recommendation
Keep only the Iter::singleton(a) suggestion as shown in the changes
Reasoning
Having a single recommended way to perform an operation improves code consistency and reduces confusion. The Iter::singleton(a) approach is more idiomatic and clearer in expressing the intent compared to creating a single-element array and converting it to an iterator.

More efficient iterator creation with singleton

Category
Performance
Code Snippet
[a].iter() vs Iter::singleton(a)
Recommendation
Continue encouraging Iter::singleton(a) usage
Reasoning
Using Iter::singleton(a) directly creates an iterator without the overhead of creating a temporary array first, making it potentially more efficient than [a].iter()

Documentation update suggestion

Category
Maintainability
Code Snippet
/// Returns a new iterator with the element a prepended to the original iterator.
Recommendation
Add an example showing the recommended usage with Iter::singleton in the method documentation
Reasoning
Including examples of the recommended alternative directly in the documentation helps users migrate away from deprecated methods more effectively

@coveralls
Copy link
Collaborator

coveralls commented Jun 24, 2025

Pull Request Test Coverage Report for Build 118

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.361%

Totals Coverage Status
Change from base Build 104: 0.0%
Covered Lines: 3452
Relevant Lines: 3863

💛 - Coveralls

@peter-jerry-ye peter-jerry-ye enabled auto-merge (rebase) June 27, 2025 08:53
auto-merge was automatically disabled June 27, 2025 08:57

Head branch was pushed to by a user without write access

@illusory0x0 illusory0x0 force-pushed the fix-deprecated-msg branch 3 times, most recently from 8f07279 to f9b7c4c Compare June 27, 2025 08:59
@illusory0x0 illusory0x0 changed the title docs: keep depreated message more simple, docs(Iter): keep deprecated message more simple, Jun 27, 2025
`Iter::singleton(a) + self` is more clear than  `[a].iter() + self` and conforms to the conventions of other programming languages.
@peter-jerry-ye peter-jerry-ye enabled auto-merge (rebase) June 27, 2025 09:07
@peter-jerry-ye peter-jerry-ye merged commit 07bc2d3 into moonbitlang:main Jun 27, 2025
10 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.

3 participants