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

StrPrelude::char_at() confuses people by accept byte index instead of char index #19724

Closed
liigo opened this issue Dec 11, 2014 · 3 comments
Closed

Comments

@liigo
Copy link
Contributor

liigo commented Dec 11, 2014

If we do not want to change its semantic, I would like propose to rename it to char_at_byte_position, or just remove the method. It is not very useful to get a char from byte index. Similar to char_at_reverse.

@steveklabnik
Copy link
Member

/cc @aturon

@Gankra
Copy link
Contributor

Gankra commented Dec 11, 2014

There is a standard here: all index-based operations work on bytes. This is the only reasonable choice for a "random" access operation on a UTF8 string. We could definitely consider renaming to code_point_at, or just remove the method, though.

I do not believe we have done a fine-grain stablization pass for str, only String. See #17438 for details.

@alexcrichton
Copy link
Member

Yes, as @gankro mentions this is consistent with our current conventions with indexing and strings. I'm working on a patch for the fine-grained stabilization of str but I'm likely going to leave these methods as unstable for now as it's unclear how certain we are of them in a 1.0 world.

For now though I'm going to close this issue as the usage of indexing and lack of mentioning "byte" is consistent with our current conventions with string apis.

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

No branches or pull requests

4 participants