summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-20 11:16:11 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-20 11:16:11 +0000
commitdb690b368f7e05b242f2e775f620f35ab0df5bc3 (patch)
treec70d8e82bf81515e48b7bd2701595d6e62ce93e3 /README.md
parentf027a812707d68ca0690b7544175b9f302dd57ad (diff)
Smart derives...
Diffstat (limited to 'README.md')
-rw-r--r--README.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/README.md b/README.md
index c0275c7..cdba0f3 100644
--- a/README.md
+++ b/README.md
@@ -662,7 +662,15 @@ Decorate functions and structs to modify compiler behavior.
| `@weak` | Fn | Weak symbol linkage. |
| `@section("name")` | Fn | Place code in specific section. |
| `@noreturn` | Fn | Function does not return (e.g. exit). |
-| `@derived(...)` | Struct | Auto-implement traits (e.g. `Debug`). |
+| `@derive(...)` | Struct | Auto-implement traits. Supports `Debug`, `Eq` (Smart Derive), `Copy`, `Clone`. |
+
+### Smart Derives
+
+Zen C provides "Smart Derives" that respect Move Semantics:
+
+- **`@derive(Eq)`**: Generates an equality method that takes arguments by reference (`fn eq(self, other: T*)`).
+ - When comparing two non-Copy structs (`a == b`), the compiler automatically passes `b` by reference (`&b`) to avoid moving it.
+ - Recursive equality checks on fields also prefer pointer access to prevent ownership transfer.
### 14. Inline Assembly