Uh oh!
There was an error while loading. Please reload this page.
Replace slice methods tail(), init() with pop_first(), pop_last() - #24184
Replace slice methods tail(), init() with pop_first(), pop_last()#24184lilyball wants to merge 2 commits into
Conversation
The `init`/`tail` terminology is not obvious to anyone who hasn't already seen it in another language like Haskell, and we already got rid of `head()` (the common pair for `tail()`). Instead of merely renaming these functions, turn them into separate functions fn pop_first(&self) -> Option<(&T, &[T])>; fn pop_last(&self) -> Option<(&T, &[T])>; as these functions are often used in a context where the first/last element wants to be inspected and it's a bit more ergonomic this way.
rust-highfive
commented
Apr 8, 2015
r? @gankro (rust_highfive has picked a reviewer for you, use r? to override) |
GuillaumeGomez
commented
Apr 8, 2015
I prefer the first/tail naming. It makes sense from my point of view and I don't really like yours (I speak about functions naming) ^^'. I never developped in Haskell but |
nikomatsakis
commented
Apr 8, 2015
Hmm, I have mixed reactions. I admire your attempt to find something categorically better than
(Also, in collections, we tend to use the names "front" and "back", so maybe we should stick to that, rather than "first/last". Or does that seem specific to |
nikomatsakis
commented
Apr 8, 2015
bors
commented
Apr 8, 2015
☔ The latest upstream changes (presumably #23998) made this pull request unmergeable. Please resolve the merge conflicts. |
alexcrichton
commented
May 1, 2015
This has been sitting here for awhile now, so I'm going to close this in favor of the associated RFC. |
The
init/tailterminology is not obvious to anyone who hasn'talready seen it in another language like Haskell, and we already got rid
of
head()(the common pair fortail()).Instead of merely renaming these functions, turn them into separate
functions
as these functions are often used in a context where the first/last
element wants to be inspected and it's a bit more ergonomic this way.
Fixes#24141.
[breaking-change]