Closed
Description
In chapter 20 of the guide you write that x.foo().bar().baz()
has better readability than baz(bar(foo(x)))
. However, afterwards you only give an example of a simple fn 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...
Metadata
Metadata
Assignees
Labels
No labels