Skip to content

RFC: New method for str: str::chunks(usize) #3818

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

Closed
wants to merge 6 commits into from

Conversation

tkr-sh
Copy link

@tkr-sh tkr-sh commented May 24, 2025

tldr;slice::chunks but for &str with chunks being substrings as &str of chunk_size length.

Rendered

@tkr-sh
Copy link
Author

tkr-sh commented May 24, 2025

This is my first time writing an RFC, so sorry if I missed something! ^^'

@ptrca
Copy link

ptrca commented May 24, 2025

The same related proposal was recently rejected in rust-lang/libs-team#590

Anyway, instead of an RFC, this API should be proposed as an ACP in https://github.com/rust-lang/libs-team

@pthariensflame
Copy link
Contributor

The same proposal was recently rejected in rust-lang/libs-team#590

Not quite the same proposal; that one proposed to chunk on bytes and this one proposes to chunk on chars.

@tkr-sh
Copy link
Author

tkr-sh commented May 24, 2025

yes!

Given the issues related to UTF-8 boundaries causing potential foot-guns [...]

So this RFC doesn't have the same "problems" as the previous one

(Also, I think that .chunks(n).map(|s: &str| ...) is better than .chunks(n).map(|s: &[char]| ...) or &[u8])

@tkr-sh
Copy link
Author

tkr-sh commented May 25, 2025

Anyway, instead of an RFC, this API should be proposed as an ACP in https://github.com/rust-lang/libs-team

rust-lang/libs-team#592

@ehuss
Copy link
Contributor

ehuss commented May 26, 2025

I'm going to close in favor of rust-lang/libs-team#592.

@ehuss ehuss closed this May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants