-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
WIP Partially stabilize StrExt
for pattern-using methods
#20058
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
r? @aturon |
36a46aa
to
159245c
Compare
cc @alexcrichton I don't think I will have time to re-review this, but the initial draft looked good to me. |
I will take a look at this soon, thanks in advance though @Kimundi! |
@@ -1408,10 +1536,19 @@ pub trait StrPrelude for Sized? { | |||
/// assert_eq!(v, vec![""]); | |||
/// # } | |||
/// ``` | |||
fn splitn<'a, Sep: CharEq>(&'a self, count: uint, sep: Sep) -> CharSplitsN<'a, Sep>; | |||
#[stable] | |||
#[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've generally used the #[inline]
tag primarily to ensure that something can be inlined across crates, but because this is generic I think it will be instantiated across crates regardless. Did you need to add the #[inline]
tag here (and a few places below) for other reasons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er but if you're just copying all the implementations from below up here don't worry about it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, for now I just copied inline attributes.
This looks fantastic, awesome work @Kimundi! |
49ae6a3
to
54bd7c9
Compare
So, I rebased my branch, but have a few remaining questions/undecided methods:
|
Whoops |
54bd7c9
to
4d2a460
Compare
Made iterator-returning methods return newtypes Adjusted some docs to be forwards compatible with a generic pattern API
4d2a460
to
72c8f37
Compare
@Kimundi @alexcrichton I'm back from the holiday -- would you like me to take a separate reviewing pass over this PR? |
I certainly wouldn't mind ;) Mostly I'm interested in your and @alexcrichton's opinion about the questions I raised in that comment above. |
Nah I think what we have right now is fine, adding more impls should be backwards compatible.
I think it's fine being
Due to
Ok!
Sounds good to me! Thanks again @Kimundi, this is all super awesome! |
Ah I see |
This stabilizes most methods on `&str` working with patterns in a way that is forwards-compatible with a generic string pattern matching API: - Methods that are using the primary name for their operation are marked as `#[stable]`, as they can be upgraded to a full `Pattern` API later without existing code breaking. Example: `contains(&str)` - Methods that are using a more specific name in order to not clash with the primary one are marked as `#[unstable]`, as they will likely be removed once their functionality is merged into the primary one. Example: `contains_char<C: CharEq>(C)` - The method docs got changed to consistently refer to the pattern types as a pattern. - Methods whose names do not match in the context of the more generic API got renamed. Example: `trim_chars -> trim_matches` Additionally, all methods returning iterators got changed to return unique new types with changed names in accordance with the new naming guidelines. See also rust-lang/rfcs#528 Due to some deprecations and type changes, this is a [breaking-change]
This stabilizes most methods on
&str
working with patterns in a way that is forwards-compatible with a generic string pattern matching API:#[stable]
, as they can be upgraded to a fullPattern
API later without existing code breaking. Example:contains(&str)
#[unstable]
, as they will likely be removed once their functionality is merged into the primary one. Example:contains_char<C: CharEq>(C)
trim_chars -> trim_matches
Additionally, all methods returning iterators got changed to return unique new types with changed names in accordance with the new naming guidelines.
See also rust-lang/rfcs#528
Due to some deprecations and type changes, this is a
[breaking-change]