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

Do not use .as_bytes().len() on strings #2114

Merged
merged 1 commit into from
Sep 22, 2024

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Sep 22, 2024

.len() already returns the length in bytes when used on a String or a str. As this might be counter-intuitive for beginners, I've also added an extra comment. This has the benefit of preparing them to a proper use of .len() on a string.

@mo8it mo8it merged commit a55e848 into rust-lang:main Sep 22, 2024
7 checks passed
@mo8it
Copy link
Contributor

mo8it commented Sep 22, 2024

Thanks :)

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.

2 participants