## std.convert: Classes for type coersion and conversion. ## This module is imported by default. ## The Coerce class is used for type conversion that will not fail. ## Its associated methods, `from` and `into`, are used internally ## by the compiler for implicit type conversion (coersion). pub type Coerce[T] = class to(Self): T # from(T): Self ## The `from` function is automatically implemented for all types that ## implement `to`: that is, all types T that are convertable to U. pub func from[T: Coerce[U], U](self: U): T = to(self) ## The Convert class is used for type conversion that may fail. # We'll see what this breaks. pub type Convert[T, E] = class to(Self): Result[T, E]