-
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
Clarify memory structure of vectors in documentation #31666
Clarify memory structure of vectors in documentation #31666
Conversation
@@ -20,6 +20,12 @@ There’s an alternate form of `vec!` for repeating an initial value: | |||
let v = vec![0; 10]; // ten zeroes | |||
``` | |||
|
|||
Vectors store their contents as contiguous arrays of `T` on the heap. This means | |||
that they must be able to know the size of `T` at compile (that is, how many |
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.
... at compile time (that is, ...
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.
@rkruppe: Nice catch, fixed!
Closes rust-lang#31554. Contributes to rust-lang#29380.
3be559a
to
f9fe658
Compare
@bors: r+ rollup |
📌 Commit f9fe658 has been approved by |
…t-in-vec-docs, r=steveklabnik Tweak documentation to clarify the structure of `Vec`s as contiguous arrays of items in memory. Closes rust-lang#31554; contributes to rust-lang#29380. r? @steveklabnik
…t-in-vec-docs, r=steveklabnik Tweak documentation to clarify the structure of `Vec`s as contiguous arrays of items in memory. Closes rust-lang#31554; contributes to rust-lang#29380. r? @steveklabnik
…cs, r=steveklabnik Tweak documentation to clarify the structure of `Vec`s as contiguous arrays of items in memory. Closes #31554; contributes to #29380. r? @steveklabnik
@@ -11,8 +11,8 @@ let v = vec![1, 2, 3, 4, 5]; // v: Vec<i32> | |||
``` | |||
|
|||
(Notice that unlike the `println!` macro we’ve used in the past, we use square | |||
brackets `[]` with `vec!` macro. Rust allows you to use either in either situation, | |||
this is just convention.) | |||
brackets `[]` with `vec!` macro. Rust allows you to use either in either |
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.
either in either?
Tweak documentation to clarify the structure of
Vec
s as contiguous arrays of items in memory.Closes #31554; contributes to #29380.
r? @steveklabnik