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

Index and IndexMut documentation could be improved #36329

Closed
Cobrand opened this issue Sep 7, 2016 · 6 comments
Closed

Index and IndexMut documentation could be improved #36329

Cobrand opened this issue Sep 7, 2016 · 6 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@Cobrand
Copy link
Contributor

Cobrand commented Sep 7, 2016

Index and IndexMut are definitely lacking in explanations.

For starters, nothing says what does v[x] do exactly. (spoilers : it's sugar for *v.index(x) and *v.index_mut(x) and not v.index(x) ; that allows things like v[x] = 5).

Index<usize> is implemented for lots of trivial types (str, String, Vec, ...), but nothing is said about Index<Range...>, and I think it would be worth showing some examples.

I'm opening this, but I'm planning to open a PR next week fixing this, unless someone else is up for it of course.

@brson brson added A-docs E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Sep 7, 2016
@marti1125
Copy link
Contributor

Hi @Cobrand I would like to work in this =D

@Cobrand
Copy link
Contributor Author

Cobrand commented Sep 11, 2016

@marti1125 Then go ahead 👍 !

@marti1125
Copy link
Contributor

@Cobrand I don't know how to start =/

@Cobrand
Copy link
Contributor Author

Cobrand commented Sep 13, 2016

Well, I could help of course, but I think you are mistaken about me; I'm not a mentor or anything, just a perfectly average contributor, so my help will be quite limited: I wouldn't like to lead you the wrong way.

I guess you could start by writing in pure english what I've described up there, and minimum requirement would be :

  • Explain what v[x] does (litterally a subtitute of *v.index(x) and *v.index_mut(x) if an lvalue is needed).
  • Adding examples of usages of v[x] (v[x] = 5, let f : &i64 = &v[x], things like this)
  • Adding examples for .index(range), for instance v[..5] if v is a slice, will return the first 5 elements as a slice. (Do the same thing with slice mut).
  • Use your imagination for creative examples

Again sorry if I misled you, I'm not a mentor in any way

@steveklabnik
Copy link
Member

, just a perfectly average contributor, so my help will be quite limited

I actually think this means that you have a great deal of ability to help; often, more experienced contributors won't realize that an explanation is too advanced, or that something is missing.

All of these seem like great improvements to me.

@Cobrand
Copy link
Contributor Author

Cobrand commented Sep 15, 2016

@marti1125 do you still want to work on this ?

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 31, 2016
improve docs for Index and IndexMut

This mainly changes the boring example of Foo/Bar of `IndexMut` into a better one.

Also added explanations about syntactic sugar for `v[index]`.

Closes rust-lang#36329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants