-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Write better module-level and type-level docs for String #30146
Conversation
@@ -139,7 +324,7 @@ impl String { | |||
/// // some bytes, in a vector | |||
/// let sparkle_heart = vec![240, 159, 146, 150]; | |||
/// | |||
/// // We know these bytes are valid, so just use `unwrap()`. | |||
/// // We know these bytes are valid, so we'll use `unwrap()`. |
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.
these two changes were made to bring this example in line with the module-level version, cc #28835
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
//! | ||
//! The `String` type is the most common string type that has ownership over the | ||
//! contents of the string. It has a close relationship with its borrowed | ||
//! counterpoint, the primitive [`str`]. |
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.
s/counterpoint/counterpart/
8ccc806
to
85a896d
Compare
//! length, and a capacity. The pointer points to an internal buffer `String` | ||
//! uses to store its data. The length is the number of elements currently | ||
//! stored in the buffer, and the capacity is the size of the buffer. As such, | ||
//! the length will always be less than or equal to the capacity. |
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.
"elements" -> "bytes" and "size of the buffer in bytes" perhaps.
85a896d
to
492f6fc
Compare
@brson updated to address the issues, other than the UTF-8 stuff. I think that's something that will have to come later. |
@bors r+ |
📌 Commit 492f6fc has been approved by |
/// | ||
/// This buffer is always stored on the heap. | ||
/// | ||
/// You can look at these with the [`as_ptr()`], [`len()`], and [`capacity()`] |
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 section is… pretty far away from the “these”. It should either be repeated what “these” are or paragraphs should be reorganised.
Part of #29376