Standard library · Traits
- The language
- Agents and tools
- Model providers
- The Anthropic API
- Talking agents
- Standard library
- Glossary
- Package docs
- Telemetry
- Robots
- Servers
- Deploying
- tin.ad
- The tin command
- How it works
On this page
Traits
The traits the library uses as bounds, such as T: Ord on sort and max. Implement one for your own type to use those functions with it.
All 3 symbols
Ord
trait Ord { fn compare(a: Self, b: Self): int } Values with an order. `compare(a, b)` is negative when a comes first, 0 when equal, positive after. A type with `compare` gets < > <= >=, sort, min and max.
Show
trait Show { fn show(x: Self): string } Values that can be shown as text. Every type has a derived `show`; write `fn T.show` to replace it.
Eq
trait Eq { fn equals(a: Self, b: Self): bool } Values that can be compared with ==. Derived from the parts; write `fn T.equals` to replace it.