-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Make Utf16CodeUnits generic and give it a public constructor. #19042
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. |
This seems like something that would be more appropriate as an iterator adaptor rather than a constructor. It seems somewhat akin to I would also be a little worried that we're hard-wiring the return value of |
This seems niche enough that it shouldn’t be in the prelude, so an iterator adaptor would have to be a trait that you have bring into scope. How is this better than a function or a constructor?
It’s a special case of
Would you prefer a newtype that hides the details of |
I believe this additional commit addresses your latter comment on the return value of I also tried making the iterator adaptor a method (through a trait) instead of a |
6e22fb3
to
75332a4
Compare
Thanks @SimonSapin! This solves what I was concerned about with respect to the return type. I'm always somewhat wary about increasing API surface area because we can. Dealing with encodings is pretty complicated and we don't want to expose any sort of full-fledged interface in the standard library as one probably won't exist here just yet. cc @aturon |
I'm personally in favor of this change. (It is perhaps a bit confusing that this lives with |
This allows encoding to UTF-16 something that is not in UTF-8, e.g. a `[char]` UTF-32 string. This might help with servo/servo#4023
75332a4
to
dff48a9
Compare
Rebased. Indeed, this only makes more generic existing functionality. I don’t mind moving it to libunicode, but libcore is where the existing |
…richton This allows encoding to UTF-16 something that is not in UTF-8, e.g. a `[char]` UTF-32 string. This might help with servo/servo#4023
This allows encoding to UTF-16 something that is not in UTF-8, e.g. a
[char]
UTF-32 string.This might help with servo/servo#4023