-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Update docs for std::str #40682
Update docs for std::str #40682
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Hi @tigleym ! Thank you! There's an issue here though; these docs seem to be for rust/src/libcollections/str.rs Lines 11 to 13 in a559452
//! .
Mind moving them up there and then we can give it a deeper review? Thanks 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor nits, thank so you much!
src/libcollections/str.rs
Outdated
@@ -10,9 +10,28 @@ | |||
|
|||
//! Unicode string slices. | |||
//! | |||
//! The `&str` type is one of the two main string types, the other being `String`. | |||
//! Unlike its `String` counterpart, its contents are borrowed and therefore | |||
//! cannot be moved someplace else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty solid, but I would probably end up just ending the sentence after "borrowed", as you can move &str
values, just not what they point to, which is very tricky and not really relevant here, IMHO.
src/libcollections/str.rs
Outdated
//! cannot be moved someplace else. | ||
//! | ||
//! # Basic Usage | ||
//! A basic string declaration of `&str` type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you insert a //!
above this line, to give it some space?
Also, I might say "Defining a variable with the type &str
" here, sounds a teeny bit more natural.
src/libcollections/str.rs
Outdated
//! We can explicitly specify `hello_world`'s lifetime as well: | ||
//! | ||
//! ``` | ||
//! let hello_world:&'static str = "Hello, world!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after :
, please!
@bors: r+ rollup thanks a ton! |
📌 Commit da74e86 has been approved by |
Update docs for std::str fixes rust-lang#29375 I noticed there are docs for the `str` primitive type, which contained extensive examples, so my additions give a more general explanation of `&str`. But please let me know if something can be explained more or changed. r? @steveklabnik
Update docs for std::str fixes rust-lang#29375 I noticed there are docs for the `str` primitive type, which contained extensive examples, so my additions give a more general explanation of `&str`. But please let me know if something can be explained more or changed. r? @steveklabnik
fixes #29375
I noticed there are docs for the
str
primitive type, which contained extensive examples, so my additions give a more general explanation of&str
. But please let me know if something can be explained more or changed.r? @steveklabnik