Tin
Standard library · Traits

On this page

Standard library

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.

See also