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

Splitting variants of str::starts_with and ends_with #1262

Open
gkoz opened this issue Aug 20, 2015 · 4 comments
Open

Splitting variants of str::starts_with and ends_with #1262

gkoz opened this issue Aug 20, 2015 · 4 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@gkoz
Copy link

gkoz commented Aug 20, 2015

More often than not, when using starts_with or ends_with I actually want to do something with the remaining slice and have to split it out manually, e.g.:

    if s.starts_with(prefix) {
        let part = &s[prefix.len()..];
        // ...
    }

it would be more convenient to just do

    if let Some(part) = s.starts_split(prefix) {
        // ...
    }
@Diggsey
Copy link
Contributor

Diggsey commented Aug 20, 2015

That does seem like a much rustier approach.

@tafia
Copy link

tafia commented Aug 25, 2015

I like this too.
No sure about the name (split usually returns an array)

@diaphore
Copy link

No sure about the name (split usually returns an array)

There's already a bunch of split (some of them unstables) : split_first*, split_at* ... split_prefix would fit nicely.

@withoutboats
Copy link
Contributor

Tracking issues for related features:

@nrc nrc added the T-libs-api Relevant to the library API team, which will review and decide on the RFC. label Aug 22, 2016
mneumann referenced this issue in open-xchange/deltachat-core-rust Aug 29, 2019
This update addresses the tickets deltachat#133 and deltachat#134.

The mode of the program is now controlled by a new configuration parameter ChatMode, whose value "off" forces the program to use the "Gr." legacy prefix, and "on", which outputs the "chat$group." prefix. For reading the header both prefixes are recognized and accepted.

Function dc_create_outgoing_rfc724_mid has now a new parameter "context" to allow reading the configuration within the function.

The new convention has been reflected on the tests at the end of dc_tools.rs.

In the source the modified code sections are marked by the date and the committer name "Juha-Petri Tyrkkö".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

6 participants