# Cairo Level 4: Traits & Generics

> Level 4: Traits & Generics of the LoWisa Cairo course: Traits, Generic Types, Reusable Cairo Abstractions. 3 lessons and 9 ideas, each explained in one line.

Traits & Generics is level 4 of 14 of the [LoWisa Cairo course](/courses/cairo/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Traits

- **Traits.** A **trait** declares capability: functions a type promises: implemented in impl blocks.
- **impl blocks.** An **impl** binds a trait to a type: named implementations selectable explicitly.
- **Derive.** **derive** generates standard impls: Drop, Copy, Serde, PartialEq: one attribute, no boilerplate.

## Generic Types

- **Generic functions.** Functions take **generic** parameters with trait bounds: fn max<T, +PartialOrd<T>>.
- **Trait bounds.** A **bound** demands capability of T: the plus syntax listing what the generic needs.
- **Monomorphisation.** Generics compile per **instantiation**: abstraction without runtime dispatch cost.

## Reusable Cairo Abstractions

- **Standard traits.** The core library ships the shared **traits**: arithmetic, comparison, serialisation: implement them and join the ecosystem.
- **Generic containers.** Generic structs build reusable **containers**: typed vaults and registries, proof-friendly.
- **Simplicity for provers.** Every abstraction adds proving **cost**: Cairo design keeps the hot path humble.

## Before and after this level

- **Before:** [Level 3: Ownership & Memory](/courses/cairo/level-3-ownership-and-memory/): Cairo Memory Model, References and Snapshots, Designing Safe Data Flow.
- **Next:** [Level 5: Modules & Packages](/courses/cairo/level-5-modules-and-packages/): Modules, Scarb, Package Organisation.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does Cairo Level 4: Traits & Generics cover?

Traits, Generic Types, Reusable Cairo Abstractions: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 3: Ownership & Memory, which covers Cairo Memory Model, References and Snapshots, Designing Safe Data Flow.

## Learn Cairo on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/cairo/level-4-traits-and-generics/ · Updated 2026-11-30
