30 lines
1.2 KiB
Plaintext
30 lines
1.2 KiB
Plaintext
#! @file numeric.sakura
|
|
#! @author John Christman (sorakatadzuma@gmail.com)
|
|
#! @copyright Malunal Studios, LLC.
|
|
#! @license MIT
|
|
#!
|
|
#! Contains the numeric trait, which a type implements to have all of arithmetic,
|
|
#! and which every number has.
|
|
|
|
module core;
|
|
|
|
|
|
#! A type with arithmetic.
|
|
#!
|
|
#! It composes `additive` and `multiplicative`, and `divisible` and `modular`
|
|
#! beside them, so it asks for `add`, `sub`, `mul`, `div`, `rem`, and `negate`
|
|
#! between two values of the type, with their `equals`. `+`, `-`, `*`, `/`, and
|
|
#! `%` call them, the compound assignments such as `+=` call them too, and `-x`
|
|
#! calls `negate`. Numbers are numeric without declaring anything. It does not
|
|
#! ask for an order, so vectors and matrices can be numeric; write
|
|
#! `where T: numeric, ordered` for both.
|
|
#!
|
|
#! A type has each operator by the method that gives it, so one that means only
|
|
#! some of them declares only those, and satisfies the smaller traits this one
|
|
#! composes.
|
|
#!
|
|
#! Within a generic bounded by it, a constant such as `x + 1`, and `as` between
|
|
#! numbers, work where `T` is a number and are errors in an instance where it is
|
|
#! not.
|
|
pub trait numeric : additive, multiplicative, divisible, modular {}
|