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

vec![elem; size] with run-time size should be highly visible in docs for std::vec, std::vec::Vec and std::vec! #26723

Closed
petrochenkov opened this issue Jul 1, 2015 · 3 comments

Comments

@petrochenkov
Copy link
Contributor

It's a common beginner's problem to create a vector with run-time size filled with identical values, but the idiomatic solution is pretty much undiscoverable without asking people on IRC/StackOverflow/Reddit.

cc @steveklabnik

@steveklabnik
Copy link
Member

It's already covered in the book at least, and I thought in some of these places too. Duplicating thing everywhere isn't the answer, though. If it's not on the macro or std::vec docs, it should be, though.

@steveklabnik
Copy link
Member

This usage is already mentioned

  1. in the macro docs http://doc.rust-lang.org/stable/std/macro.vec!.html
  2. in the std::vec docs http://doc.rust-lang.org/stable/std/vec/index.html

@petrochenkov
Copy link
Contributor Author

@steveklabnik
Duplication is necessary in this case because the syntax is "exotic" and not easily discoverable, it's not a normal method which everyone knows where to find.
Also, size with runtime value has to be actually used in an example and not only mentioned in text (that's what I meant by "highly visible").

The book doesn't count because nobody starts searching in the book when met with a question "How do I create a vector of N elements?", people try to look up it in the reference (in the method list of Vec, primarily).

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

2 participants