Skip to content

doc: Insert examples with universal function call syntax #36248

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

Closed
wants to merge 2 commits into from
Closed

doc: Insert examples with universal function call syntax #36248

wants to merge 2 commits into from

Conversation

EdorianDark
Copy link
Contributor

No description provided.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@frewsxcv
Copy link
Member

frewsxcv commented Sep 3, 2016

failures:

---- f32::f32::atan2_0 stdout ----
    error: no associated item named `EPSILON` found for type `f32` in the current scope
  --> <anon>:16:29
   |
16 | assert!(abs_difference_1 <= f32::EPSILON);
   |                             ^^^^^^^^^^^^

error: no associated item named `EPSILON` found for type `f32` in the current scope
  --> <anon>:17:29
   |
17 | assert!(abs_difference_2 <= f32::EPSILON);
   |                             ^^^^^^^^^^^^

error: aborting due to previous error(s)

thread 'f32::f32::atan2_0' panicked at 'Box<Any>', src/librustc/session/mod.rs:171
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    f32::f32::atan2_0

test result: FAILED. 545 passed; 1 failed; 19 ignored; 0 measured

error: test failed

@frewsxcv
Copy link
Member

frewsxcv commented Sep 3, 2016

In my opinion, I don't think we need to display both the method call syntax and the UFCS syntax, it seems redundant.

@EdorianDark
Copy link
Contributor Author

In my opinion the examples are mainly for persons new to rust, which may not yet know about UFCS.
And coming from a mathematical standpoint something like "x.max(y)" looks wrong.
The function max is defined as a function with 2 parameters, which would look like "max(x,y).
Therefore I think presenting both call syntaxes makes it easier to understand.

In the example for atan2 I did not add any lines of code, do you think that is OK?

@EdorianDark
Copy link
Contributor Author

Currently the example for atan2 explains the implementation.
Can I change it into a explanation of the application, finding the angle for a given point?

@EdorianDark EdorianDark changed the title Insert examples with universal function call syntax. doc: Insert examples with universal function call syntax. Sep 7, 2016
@EdorianDark EdorianDark changed the title doc: Insert examples with universal function call syntax. doc: Insert examples with universal function call syntax for float Sep 7, 2016
@EdorianDark EdorianDark changed the title doc: Insert examples with universal function call syntax for float doc: Insert examples with universal function call syntax Sep 7, 2016
@aturon
Copy link
Member

aturon commented Sep 27, 2016

Thanks for the PR, but I have to agree with @frewsxcv: this is not the place to teach UFCS. In addition, while the method notation may seem strange from a mathematical standpoint, it was a choice made in the API design (as opposed to using free functions) and we should present the API as intended to be used.

I'm going to close this out for the time being.

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

Successfully merging this pull request may close these issues.

4 participants