-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Replace slice methods tail(), init() with pop_first(), pop_last() #24184
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.
r? @gankro (rust_highfive has picked a reviewer for you, use r? to override) |
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 |
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 |
☔ The latest upstream changes (presumably #23998) made this pull request unmergeable. Please resolve the merge conflicts. |
This has been sitting here for awhile now, so I'm going to close this in favor of the associated RFC. |
The
init
/tail
terminology 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]