You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/attributes/derive.md
+22-20Lines changed: 22 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,29 +4,31 @@ r[attributes.derive]
4
4
r[attributes.derive.intro]
5
5
The *`derive` attribute* allows new [items] to be automatically generated for data structures.
6
6
7
+
> [!EXAMPLE]
8
+
> The following example will create an [`impl` item] for the [`PartialEq`] and [`Clone`] traits for `Foo`, and the type parameter `T` will be given the `PartialEq` or `Clone` constraints for the appropriate `impl`:
9
+
>
10
+
> ```rust
11
+
> #[derive(PartialEq, Clone)]
12
+
> structFoo<T> {
13
+
> a:i32,
14
+
> b:T,
15
+
> }
16
+
> ```
17
+
>
18
+
> Thegenerated `impl` for `PartialEq` isequivalentto
For example, the following will create an [`impl` item] for the [`PartialEq`] and [`Clone`] traits for `Foo`, and the type parameter `T` will be given the `PartialEq` or `Clone` constraints for the appropriate `impl`:
11
-
12
-
```rust
13
-
#[derive(PartialEq, Clone)]
14
-
structFoo<T> {
15
-
a:i32,
16
-
b:T,
17
-
}
18
-
```
19
-
20
-
The generated `impl` for `PartialEq` is equivalent to
0 commit comments