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
+42
View File
@@ -0,0 +1,42 @@
---
title: Traits & Impls
description: Defining traits, trait bounds, and implementation blocks.
icon: Puzzle
---
### Traits
```mist
pub trait Drawable {
void draw(&self);
}
pub trait Comparable<T> : Eq {
i32 cmp(&self, T other);
}
```
Trait requirements are specified after `:`:
```mist
trait MyTrait : SuperTrait + OtherTrait {
void required_method(&self);
void another(&self);
}
```
### Impl Blocks
```mist
impl MyType {
void method(&self) { }
}
impl Trait for MyType {
void method(&self) { }
}
impl<T> GenericTrait<T> for MyType {
void method(&self, T value) { }
}
```