std/traits
import std/traits to use it. Source: src/std/traits.iyi at v0.18.0.
The imports are what makes Hashable true rather than declared. hash_key forwards to the value's own hash, and the prelude defines hash for Int32, String and a handful more; every other integer's lives in std/int, both floats' in std/float, and a named tuple's in std/tuple. Importing neither number module, impl Hashable for Int16 forwarded to Object#hash — the type's id, one slot for every value of the type — so 1_i16.hash == 31337_i16.hash was true, and 1.5.hash == 31337.5.hash with it. A trait may not promise what the module implementing it has not loaded (SPEC.md II.8).
Each named, though std/float imports std/int itself: an integer's hash is not a thing to reach through a float, and a rule that holds only while somebody else's import survives is not held.
Comparabletrait
pub trait Comparable
def <(other : self) : Bool
def <=(other : self) : Bool
abstract def <=>(other : self) : Int32
def ==(other : self) : Bool
def >(other : self) : Bool
def >=(other : self) : Bool
def between?(min : self, max : self) : Bool
def clamp(min : self, max : self) : self
def clamp(range : Range) : self
endHashabletrait
pub trait Hashable
abstract def hash_key : Int32
endNumtrait
pub trait Num : ::Std::Traits::Comparable
abstract def add(other : self) : self
abstract def mul(other : self) : self
abstract def self.one : self
# Class-level requirements. `Enumerable#sum` and `#product` need an additive
# and a multiplicative identity, and an identity belongs to the type, not to
# any value of it — there is no element to ask when the collection is empty.
abstract def self.zero : self
endComparable for Int32impl
impl Comparable for Int32
def <=>(other : self) : Int32
endNum for Int32impl
impl Num for Int32
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Int32impl
impl Hashable for Int32
def hash_key : Int32
endComparable for Int64impl
impl Comparable for Int64
def <=>(other : self) : Int32
endNum for Int64impl
impl Num for Int64
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Int64impl
impl Hashable for Int64
def hash_key : Int32
endComparable for UInt8impl
impl Comparable for UInt8
def <=>(other : self) : Int32
endNum for UInt8impl
impl Num for UInt8
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for UInt8impl
impl Hashable for UInt8
def hash_key : Int32
endComparable for UInt64impl
impl Comparable for UInt64
def <=>(other : self) : Int32
endNum for UInt64impl
impl Num for UInt64
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for UInt64impl
impl Hashable for UInt64
def hash_key : Int32
endComparable for Float64impl
impl Comparable for Float64
def <=>(other : self) : Int32
endNum for Float64impl
impl Num for Float64
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Float64impl
impl Hashable for Float64
def hash_key : Int32
endComparable for Stringimpl
impl Comparable for String
# `<=>` is not a method the prelude's `String` has, so this was a call
# nobody could make; `<` and `==` are what it does have.
def <=>(other : self) : Int32
endHashable for Stringimpl
impl Hashable for String
def hash_key : Int32
endComparable for Charimpl
impl Comparable for Char
def <=>(other : self) : Int32
endHashable for Charimpl
impl Hashable for Char
def hash_key : Int32
endHashable for Boolimpl
impl Hashable for Bool
def hash_key : Int32
endComparable for Int8impl
impl Comparable for Int8
def <=>(other : self) : Int32
endNum for Int8impl
impl Num for Int8
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Int8impl
impl Hashable for Int8
def hash_key : Int32
endComparable for Int16impl
impl Comparable for Int16
def <=>(other : self) : Int32
endNum for Int16impl
impl Num for Int16
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Int16impl
impl Hashable for Int16
def hash_key : Int32
endComparable for UInt16impl
impl Comparable for UInt16
def <=>(other : self) : Int32
endNum for UInt16impl
impl Num for UInt16
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for UInt16impl
impl Hashable for UInt16
def hash_key : Int32
endComparable for UInt32impl
impl Comparable for UInt32
def <=>(other : self) : Int32
endNum for UInt32impl
impl Num for UInt32
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for UInt32impl
impl Hashable for UInt32
def hash_key : Int32
endComparable for Int128impl
impl Comparable for Int128
def <=>(other : self) : Int32
endNum for Int128impl
impl Num for Int128
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Int128impl
impl Hashable for Int128
def hash_key : Int32
endComparable for UInt128impl
impl Comparable for UInt128
def <=>(other : self) : Int32
endNum for UInt128impl
impl Num for UInt128
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for UInt128impl
impl Hashable for UInt128
def hash_key : Int32
endComparable for Float32impl
impl Comparable for Float32
def <=>(other : self) : Int32
endNum for Float32impl
impl Num for Float32
def self.zero : self
def self.one : self
def add(other : self) : self
def mul(other : self) : self
endHashable for Float32impl
impl Hashable for Float32
def hash_key : Int32
endHashable for Tuple(*T) forall Timpl
impl Hashable for Tuple(*T) forall T
def hash_key : Int32
endHashable for NamedTuple(T) forall Timpl
impl Hashable for NamedTuple(T) forall T
def hash_key : Int32
endHashable for Array(T) forall Timpl
impl Hashable for Array(T) forall T
def hash_key : Int32
endHashable for Nilimpl
impl Hashable for Nil
def hash_key : Int32
endHashable for Symbolimpl
impl Hashable for Symbol
def hash_key : Int32
end
Comparable, Num and Hashable over the prelude's scalars, and Hashable over the other keys a table takes: tuples, named tuples, arrays, nil and symbols.