25 lines
873 B
Plaintext
25 lines
873 B
Plaintext
#! @file divisible.sakura
|
|||
|
|
#! @author John Christman (sorakatadzuma@gmail.com)
|
||
|
|
#! @copyright Malunal Studios, LLC.
|
||
|
|
#! @license MIT
|
||
|
|
#!
|
||
|
|
#! Contains the divisible trait, which asks for the method `/` calls between two
|
||
|
|
#! values of one type.
|
||
|
|
|
||
|
|
module core;
|
||
|
|
|
||
|
|
|
||
|
|
#! A type whose values divide by another of the type, giving one more.
|
||
|
|
#!
|
||
|
|
#! `a / b` calls `div`, and `a /= b` writes what it gives over `a`. A type has
|
||
|
|
#! `/` by declaring the method, and may declare others taking other types, as
|
||
|
|
#! `duration::div(&this, by: &i64)`. The trait is what generic code asks for to
|
||
|
|
#! divide two values of a type. Numbers are divisible without declaring
|
||
|
|
#! anything.
|
||
|
|
pub trait divisible {
|
||
|
|
#! Divides this value by another, as `/` does.
|
||
|
|
#! @param this The value to divide.
|
||
|
|
#! @param other The value to divide by.
|
||
|
|
#! @returns The quotient.
|
||
|
|
def div(&this, other: &self): self;
|
||
|
|
}
|