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
+34-2Lines changed: 34 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,11 +38,43 @@ You can implement `derive` for your own traits through [procedural macros].
38
38
r[attributes.derive.automatically_derived]
39
39
## The `automatically_derived` attribute
40
40
41
-
The *`automatically_derived` attribute* is automatically added to [implementations] created by the `derive` attribute for built-in traits. It has no direct effect, but it may be used by tools and diagnostic lints to detect these automatically generated implementations.
41
+
r[attributes.derive.automatically_derived.intro]
42
+
The *`automatically_derived`[attribute][attributes]* is used to annotate an [implementation] to indicate that it was automatically created by a `derive` attribute. It has no direct effect, but it may be used by tools and diagnostic lints to detect these automatically generated implementations.
43
+
44
+
> [!EXAMPLE]
45
+
> The following is an example of what the [`Clone`] derive may generate for a struct named `Example`.
46
+
> ```rust
47
+
> # structExample;
48
+
> #[automatically_derived]
49
+
> impl::core::clone::CloneforExample {
50
+
> #[inline]
51
+
> fnclone(&self) ->Example {
52
+
> Example
53
+
> }
54
+
> }
55
+
> ```
56
+
57
+
r[attributes.derive.automatically_derived.syntax]
58
+
The `automatically_derived` attributeusesthe [MetaWord] syntaxandthusdoesnottakeanyinputs.
0 commit comments