Files
sakurac/core/traits/modular.sakura
T
2026-10-28 22:13:49 -05:00

25 lines
827 B
Plaintext

#! @file modular.sakura
#! @author John Christman (sorakatadzuma@gmail.com)
#! @copyright Malunal Studios, LLC.
#! @license MIT
#!
#! Contains the modular trait, which asks for the method `%` calls between two
#! values of one type.
module core;
#! A type whose values leave a remainder when divided by another of the type.
#!
#! `a % b` calls `rem`, and `a %= b` writes what it gives over `a`. A type has
#! `%` by declaring the method. The trait is what generic code asks for to take
#! the remainder of two values of a type. Numbers are modular without declaring
#! anything.
pub trait modular {
#! The remainder of dividing this value by another, as `%` gives it.
#! @param this The value to divide.
#! @param other The value to divide by.
#! @returns The remainder.
def rem(&this, other: &self): self;
}