We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e362679 commit 4d7eee1Copy full SHA for 4d7eee1
src/doc/trpl/traits.md
@@ -492,3 +492,32 @@ If we forget to implement `Foo`, Rust will tell us:
492
```text
493
error: the trait `main::Foo` is not implemented for the type `main::Baz` [E0277]
494
```
495
+
496
+# Deriving
497
498
+Implementing traits like `Debug` and `Default` over and over again can become
499
+quite tedious. For that reason, Rust provides an [attribute][attributes] that
500
+allows you to let Rust automatically implement traits for you:
501
502
+```rust
503
+#[derive(Debug)]
504
+struct Foo;
505
506
+fn main() {
507
+ println!("{:?}", Foo);
508
+}
509
+```
510
511
+[attributes]: attributes.html
512
513
+However, deriving is limited to a certain set of traits:
514
515
+- `Clone`
516
+- `Copy`
517
+- `Debug`
518
+- `Default`
519
+- `Eq`
520
+- `Hash`
521
+- `Ord`
522
+- `PartialEq`
523
+- `PartialOrd`
0 commit comments