-
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
Return the String guide to its former glory. #21056
Conversation
let string = "Hello there."; | ||
``` | ||
|
||
Like any Rust type, string slices have an associated lifetime. A string literal |
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.
"Like any Rust reference type" maybe?
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.
agreed, fixe
r? @sfackler |
5d74940
to
e68865b
Compare
This has been updated now. |
|
||
Like vector slices, string slices are simply a pointer plus a length. This | ||
means that they're a 'view' into an already-allocated string, such as a | ||
`&'static str` or a `String`. |
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.
Using &'static str
here seems wrong, maybe "string literal"?
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.
Why is it wrong?
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.
It just seems a bit strange since the paragraph's saying that slices are a view into an already allocated string, such as a slice, but isn't that a view into an already allocated string?
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.
I guess it is strange because it's an edge case: a &'static str
is an always-allocated thing. And I tend to refer to things by their type explicitly. But I can see that. Lemme fix it.
r=me with the one last nit. |
e68865b
to
b33dfdb
Compare
@bors: r=sfackler b33dfdb rollup |
⌛ Testing commit b33dfdb with merge 1fcaec0... |
💔 Test failed - auto-mac-64-opt |
b33dfdb
to
cef8295
Compare
When we moved over to the book, we lost this.
Woo |
…kler When we moved over to the book, we lost this.
When we moved over to the book, we lost this.