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

Correct char.encode_utf16() documentation #31831

Merged
merged 2 commits into from
Feb 25, 2016
Merged

Conversation

tormol
Copy link
Contributor

@tormol tormol commented Feb 23, 2016

The "A buffer that's too small" example was calling encode_utf8().

The "A buffer that's too small" example was calling encode_utf8().
@alexcrichton
Copy link
Member

Oh actually I think that this example will fail in this updated case, a 2-element buffer is enough to encode any character in utf-16, so could you change it to a one-element buffer?

@steveklabnik steveklabnik self-assigned this Feb 23, 2016
@steveklabnik
Copy link
Member

Gah, thank you for this. Agree with @alexcrichton 's suggestion.

@tormol
Copy link
Contributor Author

tormol commented Feb 24, 2016

The example still succeeds (at returning None) since the buffer is empty.
If I did just that the example would fail since encode_utf16() would return Some(1).
The first example already uses a buffer with length 1.

Do you mean changing both examples to use a different char that requires two u16s?

@alexcrichton
Copy link
Member

Ah yeah I wasn't sure if ß required two u16 elements or not, but yeah the example I believe intends to show one that requires two but the buffer is of length 1

@tormol
Copy link
Contributor Author

tormol commented Feb 24, 2016

I have changed both examples to use 𝕊 which requires two u16s. (and updated the buffer sizes and expected results accordingly.)

The build failure seems unrelated.

(Do I need to comment after adding commits?)

@steveklabnik
Copy link
Member

(Do I need to comment after adding commits?)

Yeah, GitHub doesn't notify us when you push :(

(I'll restart Travis just in case)

@alexcrichton
Copy link
Member

@bors: r+ d34c6ee

Thanks!

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 25, 2016
The "A buffer that's too small" example was calling encode_utf**8**().
bors added a commit that referenced this pull request Feb 25, 2016
@bors bors merged commit d34c6ee into rust-lang:master Feb 25, 2016
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