You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-11-27 00:21:07 +02:00
docs: improve language in methods-and-traits section (#2881)
I asked Gemini to review the English for inconsistencies and grammar mistakes. This is the result and I hope it's useful! As a non-native speaker, it is hard for me to evaluate the finer details, so let me know if you would like to see changes (or even better: make them directly in the PR with the suggestion function). --------- Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
This commit is contained in:
@@ -30,7 +30,7 @@ fn main() {
|
||||
macros to add useful functionality. For example, `serde` can derive
|
||||
serialization support for a struct using `#[derive(Serialize)]`.
|
||||
|
||||
- Derivation is usually provided for traits that have a common boilerplate-y
|
||||
- Derivation is usually provided for traits that have a common boilerplate
|
||||
implementation that is correct for most cases. For example, demonstrate how a
|
||||
manual `Clone` impl can be repetitive compared to deriving the trait:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ minutes: 15
|
||||
# Exercise: Logger Trait
|
||||
|
||||
Let's design a simple logging utility, using a trait `Logger` with a `log`
|
||||
method. Code which might log its progress can then take an `&impl Logger`. In
|
||||
method. Code that might log its progress can then take an `&impl Logger`. In
|
||||
testing, this might put messages in the test logfile, while in a production
|
||||
build it would send messages to a log server.
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ There are several common receivers for a method:
|
||||
transmitted. Complete ownership does not automatically mean mutability.
|
||||
- `mut self`: same as above, but the method can mutate the object.
|
||||
- No receiver: this becomes a static method on the struct. Typically used to
|
||||
create constructors which are called `new` by convention.
|
||||
create constructors that are called `new` by convention.
|
||||
|
||||
<details>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Associated Types
|
||||
|
||||
Associated types are placeholder types which are supplied by the trait
|
||||
Associated types are placeholder types that are supplied by the trait
|
||||
implementation.
|
||||
|
||||
```rust,editable
|
||||
|
||||
Reference in New Issue
Block a user