-
Notifications
You must be signed in to change notification settings - Fork 532
Grammar: Functions, methods, impl, traits, extern. #430
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
Conversation
Question: Would it be clearer if Also, I missed the 2015/2018 difference of trait functions taking optional named parameters. I'm thinking of documenting the 2015 behavior with a dagger (or something) that links to the section that describes that it is no longer allowed. Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, left a few small comments
src/items/functions.md
Outdated
> _BlockWithInnerAttributes_ :\ | ||
> `{`\ | ||
> [_InnerAttribute_]<sup>\*</sup>\ | ||
> [_Statement_]<sup>\*</sup>\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an optional expression
src/items/traits.md
Outdated
@@ -115,6 +135,23 @@ let circle = Box::new(circle) as Box<dyn Circle>; | |||
let nonsense = circle.radius() * circle.area(); | |||
``` | |||
|
|||
## Unsafe traits | |||
|
|||
Traits that begin with the `unsafe` keyword indicate that *implementing* the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be clearer as "Trait items that..."
src/items/traits.md
Outdated
|
||
Traits that begin with the `unsafe` keyword indicate that *implementing* the | ||
trait may be [unsafe]. It is safe to use a correctly implemented unsafe trait. | ||
The [trait implementation] must also include the `unsafe` keyword. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"include" should be "start with" or "begin with"
I'm not sure how arbitrary self types changes anything here. It would probably be slightly better for methods to only include things with |
Thanks for taking a look. I've done some updates to fix a bunch of things and specify functions and methods separately. I added some detail about pattern limitations for parameters. |
These all are intertwined with the "function" definition. Updates grammar for: - Functions and methods - Extern blocks - Implementation - Traits
- Review comments. - Separate Function and Method in impl. - Move _Method_ grammar to the section discussing methods. - Be a little more explicit about `self` types. - Fix block ending with expression for functions. - Fix extern blocks not supporting patterns. - Fix trait functions/methods having optional patterns, and the pattern restrictions.
d0bb7a7
to
028fd75
Compare
I attempted to explain the 2018 edition changes for trait parameter patterns. |
Thanks! |
These all are intertwined with the "function" definition. Updates grammar for: