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 for str::find say closure but don't use a closuer #45327

Closed
steveklabnik opened this issue Oct 16, 2017 · 6 comments · Fixed by #45349
Closed

docs for str::find say closure but don't use a closuer #45327

steveklabnik opened this issue Oct 16, 2017 · 6 comments · Fixed by #45349
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. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority

Comments

@steveklabnik
Copy link
Member

https://doc.rust-lang.org/stable/std/primitive.str.html#examples-21

More complex patterns with closures:

... but it uses point-free style, not closures.

We should probably show both.

@steveklabnik steveklabnik added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Oct 16, 2017
@pvdrz
Copy link
Contributor

pvdrz commented Oct 17, 2017

I'd like to take care of this one

@steveklabnik
Copy link
Member Author

@christianpoveda that'd be great! Do you know what needs to be done, or do you need some help/advice?

@pvdrz
Copy link
Contributor

pvdrz commented Oct 17, 2017

If I understand, you want to change s.find(char::foo) by s.find(|x| x.foo()), right?

@LeopoldArkham
Copy link

It would be nice to have both so people still know they can use UFCS syntax (as long as it takes a char and returns a boolean) which is cleaner in trivial cases.
Perhaps add an example that looks for a delimiter symbol (-/_.)

@steveklabnik
Copy link
Member Author

If I understand, you want to change s.find(char::foo) by s.find(|x| x.foo()), right?

I'd say "add" rather than change, it's nice to show both.

@LeopoldArkham just so you know, it's not UFCS anymore, but fully qualified syntax.

@TimNN TimNN added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Oct 17, 2017
@LeopoldArkham
Copy link

TIL; Thank you steve!

kennytm added a commit to kennytm/rust that referenced this issue Oct 19, 2017
…r=steveklabnik

added examples of closures for str::find

This is an attempt to fix rust-lang#45327

r? @steveklabnik
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. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants