-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
rust-guide::20 method syntax - Suggestion to explain method chaining and types of self #16969
Comments
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jan 23, 2015
flaper87
added a commit
to flaper87/rust
that referenced
this issue
Jan 23, 2015
flaper87
added a commit
to flaper87/rust
that referenced
this issue
Jan 24, 2015
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
Apr 20, 2024
Log flycheck errors Resolves rust-lang#16969 The non-cargo messages are appended to the error strings here; https://github.com/rust-lang/rust-analyzer/blob/7a8374c162c64c17e865b98aad282d16b16e96d6/crates/flycheck/src/lib.rs#L460-L482 that one is formatted into `Err` here; https://github.com/rust-lang/rust-analyzer/blob/7a8374c162c64c17e865b98aad282d16b16e96d6/crates/flycheck/src/command.rs#L144-L155 and finally, this PR appends it at the end of existing Flycheck error message
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
Apr 20, 2024
Log flycheck errors Resolves rust-lang#16969 The non-cargo messages are appended to the error strings here; https://github.com/rust-lang/rust-analyzer/blob/7a8374c162c64c17e865b98aad282d16b16e96d6/crates/flycheck/src/lib.rs#L460-L482 that one is formatted into `Err` here; https://github.com/rust-lang/rust-analyzer/blob/7a8374c162c64c17e865b98aad282d16b16e96d6/crates/flycheck/src/command.rs#L144-L155 and finally, this PR appends it at the end of existing Flycheck error message
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cc @steveklabnik
In chapter 20 of the guide you write that
x.foo().bar().baz()
has better readability thanbaz(bar(foo(x)))
. However, afterwards you only give an example of a simplefn area(&self) -> f64
method.I suggest adding an example of a method that allows chaining. Something like
fn foo(&mut self) -> &mut T {...}
, where T is the type of the struct.In addition, it would be nice to explain the distinction between methods that take 'self', 'mut self', '&self' and '&mut self'. All of those can be used to implement method chaining, but with different purposes - some can be used to mutate the original value, while others can't, etc...
The text was updated successfully, but these errors were encountered: