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

Removed unneccessary _iter suffixes from the various APIs #10622

Closed
wants to merge 1 commit into from

Conversation

Kimundi
Copy link
Member

@Kimundi Kimundi commented Nov 23, 2013

This PR removes almost all _iter suffixes in various APIs of the codebase that return Iterators, as discussed in #9440.

As a summarize for the intend behind this PR:

  • Iterators are the recommended way to provide a potentially lazy list of values, no need to name them painfully verbose. If anything, functions that return a specific container type should have more verbose names.
  • We have a static type system, so no need to encode the return value of a constructor function into its name.

Following is a possibly incomplete list of all renamings I performed in the codebase. For a few of them I'm a bit unsure whether the new name still properly expresses their functionality, so feedback would be welcome:

&str : word_iter()             -> words()
       line_iter()             -> lines()
       any_line_iter()         -> lines_any()
       iter()                  -> chars()
       char_offset_iter()      -> char_indices()
       byte_iter()             -> bytes()
       split_iter()            -> split()
       splitn_iter()           -> splitn()
       split_str_iter()        -> split_str()
       split_terminator_iter() -> split_terminator()
       matches_index_iter()    -> match_indices()
       nfd_iter()              -> nfd_chars()
       nfkd_iter()             -> nfkd_chars()

&[T] : split_iter()        -> split()
       splitn_iter()       -> splitn()
       window_iter()       -> windows()
       chunk_iter()        -> chunks()
       permutations_iter() -> permutations()

extra:bitv::Bitv :  rev_liter()    -> rev_iter()
                    common_iter()  -> commons()
                    outlier_iter() -> outliers()

extra::treemap::{...} : lower_bound_iter() -> lower_bound()
                        upper_bound_iter() -> upper_bound()

std::trie::{...} : bound_iter()       -> bound()
                   lower_bound_iter() -> lower_bound()
                   upper_bound_iter() -> upper_bound()

rustpkg::package_id::{...} : prefixes_iter() -> prefixes()

std::hashmap::{...} : difference_iter()           -> difference()
                      symmetric_difference_iter() -> symmetric_difference()
                      intersection_iter()         -> intersection()
                      union_iter()                -> union()

std::path::{posix, windows} : component_iter()     -> components()
                              str_component_iter() -> str_components()

... not showing all identical renamings for reverse versions

I'm also planning a few more changes, like removing all unnecessary _rev constructors (#9391), or reducing the split variants on &str to a more versatile and concise system.

@emberian
Copy link
Member

👍 awesome

@alexcrichton
Copy link
Member

I am very much in favor of this. If I hear no objections in the next day or so, I will r+ this.

@huonw
Copy link
Member

huonw commented Nov 24, 2013

(@Kimundi if you do receive feedback and change things, could you keep the PR description up-to-date, so it acts as a cheatsheet/FAQ for people updating to the new names.)

@Kimundi
Copy link
Member Author

Kimundi commented Nov 25, 2013

Rebased and updated, and also updated the table to list the string normalization iterators, because I somehow missed them.

bors added a commit that referenced this pull request Nov 26, 2013
This PR removes almost all `_iter` suffixes in various APIs of the codebase that return Iterators, as discussed in #9440.

As a summarize for the intend behind this PR:

- Iterators are the recommended way to provide a potentially lazy list of values, no need to name them painfully verbose. If anything, functions that return a specific container type should have more verbose names.
- We have a static type system, so no need to encode the return value of a constructor function into its name.

Following is a possibly incomplete list of all renamings I performed in the codebase. For a few of them I'm a bit unsure whether the new name still properly expresses their functionality, so feedback would be welcome:

~~~
&str : word_iter()             -> words()
       line_iter()             -> lines()
       any_line_iter()         -> lines_any()
       iter()                  -> chars()
       char_offset_iter()      -> char_indices()
       byte_iter()             -> bytes()
       split_iter()            -> split()
       splitn_iter()           -> splitn()
       split_str_iter()        -> split_str()
       split_terminator_iter() -> split_terminator()
       matches_index_iter()    -> match_indices()
       nfd_iter()              -> nfd_chars()
       nfkd_iter()             -> nfkd_chars()
      
&[T] : split_iter()        -> split()
       splitn_iter()       -> splitn()
       window_iter()       -> windows()
       chunk_iter()        -> chunks()
       permutations_iter() -> permutations()
      
extra:bitv::Bitv :  rev_liter()    -> rev_iter()
                    common_iter()  -> commons()
                    outlier_iter() -> outliers()

extra::treemap::{...} : lower_bound_iter() -> lower_bound()
                        upper_bound_iter() -> upper_bound()
                       
std::trie::{...} : bound_iter()       -> bound()
                   lower_bound_iter() -> lower_bound()
                   upper_bound_iter() -> upper_bound()

rustpkg::package_id::{...} : prefixes_iter() -> prefixes()

std::hashmap::{...} : difference_iter()           -> difference()
                      symmetric_difference_iter() -> symmetric_difference()
                      intersection_iter()         -> intersection()
                      union_iter()                -> union()
                     
std::path::{posix, windows} : component_iter()     -> components()
                              str_component_iter() -> str_components()

... not showing all identical renamings for reverse versions
~~~

---

I'm also planning a few more changes, like removing all unnecessary `_rev` constructors (#9391), or reducing the `split` variants on `&str` to a more versatile and concise system.
@bors bors closed this Nov 26, 2013
cadencemarseille added a commit to cadencemarseille/rust-pcre that referenced this pull request Nov 28, 2013
See also rust-lang/rust#10622 - Removed unneccessary `_iter` suffixes from the various APIs
@brendanzab
Copy link
Member

Woops, I might have introduced another _iter in #10688. Any idea for a better name for recv_iter?

@emberian
Copy link
Member

emberian commented Dec 1, 2013

.messages() ?

cadencemarseille added a commit to cadencemarseille/rust-pcre that referenced this pull request Dec 1, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 23, 2023
Clippy Book Chapter Updates Reborn: Lint Passes

This PR adds a new chapter to the book: "Lint passes". No major changes apart from some re-phrasing, fixing typos... etc.

## Notes

- Requires rust-lang#10595 to be merged before this one (Or else, a link will be broken).
- To talk about the whole project, please use the tracking issue for the project rust-lang#10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Lint passes" chapter to the book
r? `@flip1995`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 24, 2023
Clippy Book Chapter Updates Reborn: Method Checking

This PR adds a new chapter to the book: "Method Checking". Some major re-phrasing was done and some changes in the code comments (apart from grammar and minor changes).

## Notes

- Requires rust-lang#10595 **and** rust-lang#10622 to be merged before this, or else several links will be broken
- To talk about the whole project, please use the tracking issue for the project rust-lang#10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Method Checking" chapter to the book.

r? `@flip1995`
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.

6 participants