Docs rewrite

This commit is contained in:
2026-07-03 10:23:45 +02:00
parent 6cda69044a
commit ec857525b4
23 changed files with 1084 additions and 1134 deletions
+39
View File
@@ -0,0 +1,39 @@
---
title: Generics
description: Generic functions, structs, enums, trait bounds, and lifetimes.
icon: Braces
---
```mist
// Generic function
T id<T>(T x)
{
x
}
// Generic struct
struct Pair<A, B> {
A first,
B second,
}
// Generic enum
enum Result<T, E> {
Ok(T),
Err(E),
}
// Generic with trait bounds
T max<T : Ord>(T a, T b)
{
if a > b { a } else { b }
}
// Lifetime generics
void process<'a>(&'a str& data)
{
// ...
}
```
Generic syntax uses `<` `>` delimiters. Lifetimes are prefixed with `'`.