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

str::get_mut doc example should demonstrate mutability #44382

Closed
frewsxcv opened this issue Sep 7, 2017 · 5 comments
Closed

str::get_mut doc example should demonstrate mutability #44382

frewsxcv opened this issue Sep 7, 2017 · 5 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority

Comments

@frewsxcv
Copy link
Member

frewsxcv commented Sep 7, 2017

https://doc.rust-lang.org/nightly/std/primitive.str.html#method.get_mut

The doc example should demonstrate the effects of mutating the resulting string slice.

The easiest way I've found to demonstrate mutability with doc examples for str is to use AsciiExt: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_at_mut

@frewsxcv frewsxcv added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Sep 7, 2017
@toidiu
Copy link
Contributor

toidiu commented Sep 7, 2017

I would like to attempt this.

@frewsxcv
Copy link
Member Author

frewsxcv commented Sep 7, 2017

Long time no see @toidiu 👋 Let me know if you need any help with this or have any questions

@toidiu
Copy link
Contributor

toidiu commented Sep 8, 2017

@frewsxcv 🖖

I had a thought about how to implement this better. The current example uses the string 🗻∈🌏 where the characters have a variable byte length. This was a source of confusing when I first looked at the example (its not super obvious that 🗻 is 4 bytes).

I was thinking of changing the string to something more uniform like hello which is 1 byte per char and then applying make_ascii_uppercase(). This could also be applied to other examples.

@frewsxcv
Copy link
Member Author

frewsxcv commented Sep 8, 2017

I was thinking of changing the string to something more uniform like hello which is 1 byte per char and then applying make_ascii_uppercase(). This could also be applied to other examples.

yep, this makes sense to me 👌

@frewsxcv
Copy link
Member Author

Completed in #44467

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-low Low priority
Projects
None yet
Development

No branches or pull requests

2 participants