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

Docs: Vec<T>'s contents being contiguous could be a little more clear #31554

Closed
niconii opened this issue Feb 11, 2016 · 2 comments
Closed

Docs: Vec<T>'s contents being contiguous could be a little more clear #31554

niconii opened this issue Feb 11, 2016 · 2 comments

Comments

@niconii
Copy link
Contributor

niconii commented Feb 11, 2016

At the moment, Vec<T>'s module and type doc pages don't quite make it clear that its contents are in fact contiguous. They imply it in several places...

Vectors have O(1) indexing, amortized O(1) push (to the end) and O(1) pop (from the end).

Most fundamentally, Vec is and always will be a (pointer, capacity, length) triplet. No more, no less.

...but it would be better to make it more clear. In addition, Vec<T>'s documentation refers to it as a "growable list type", which could be misleading in light of this; "list" is more often used to mean a linked list.

Perhaps something like one of these would be better as the description line:

A contiguous growable list type with heap-allocated contents, written Vec<T> but pronounced 'vector.'

A growable array type with heap-allocated contents, written Vec<T> but pronounced 'vector.'

@GuillaumeGomez
Copy link
Member

A more global description is a nice idea. However, keeping the original text is also a nice thing, it's appreciated to have algorithm's complexity. So from my point of view, this would be perfect:

A contiguous growable list type with heap-allocated contents, written Vec but pronounced 'vector.'

A growable array type with heap-allocated contents, written Vec but pronounced 'vector.'

Vectors have O(1) indexing, amortized O(1) push (to the end) and O(1) pop (from the end).

@steveklabnik
Copy link
Member

part of #29380

dirk added a commit to dirk/rust that referenced this issue Feb 15, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 15, 2016
…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
@bors bors closed this as completed in f2bea1c Feb 16, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 16, 2016
…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
bors added a commit that referenced this issue Feb 17, 2016
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants