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

Tracking Issue for slice::Split::as_slice() #96137

Open
1 of 3 tasks
JulianKnodt opened this issue Apr 17, 2022 · 2 comments
Open
1 of 3 tasks

Tracking Issue for slice::Split::as_slice() #96137

JulianKnodt opened this issue Apr 17, 2022 · 2 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@JulianKnodt
Copy link
Contributor

JulianKnodt commented Apr 17, 2022

Feature gate: #![feature(split_as_slice)]

This is a tracking issue for:

Converting an iterator produced by .split(...) which is not fully consumed, into a slice, matching the APIs for .split(...) on Strings.

Public API

let a = [1,2,3];
let mut iter = a.split(|i| i == 2);
assert!(iter.next().is_some());
assert_eq!(iter.as_slice(), &[3]);

Steps / History

Unresolved Questions

Add impl:

#[stable(feature = "split_as_slice", since = "1.0.0")]
impl<'a, T: 'a, P: FnMut(&T) -> bool> AsRef<[T]> for Split<'a, T, P> {
    fn as_ref(&self) -> &'a [T] {
        self.as_slice()
    }
}
@JulianKnodt JulianKnodt added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Apr 17, 2022
@clarfonthey
Copy link
Contributor

Is there anything in particular blocking this from stabilisation? It's been on stable for over a year.

@dtolnay dtolnay changed the title Tracking Issue for slice::Split::Iter::as_slice() Tracking Issue for slice::Split::as_slice() Nov 24, 2024
@dtolnay
Copy link
Member

dtolnay commented Nov 24, 2024

This method was renamed from the originally proposed name core::slice::Split::remainder to as_slice as an outcome of the discussion under #92287 (comment), in which a key factor was consistency with core::str::Split::as_str.

At the same time, core::str::Split::as_str got renamed to remainder in #95644, citing that "the as_str name was confusing to users". Tracking issue: #77998

I would want this assessed and reconciled before proposing either stabilization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants