Files
sakurac/core/traits/subtractable.sakura
T

25 lines
933 B
Plaintext
Raw Normal View History

2026-10-26 10:14:11 -05:00
#! @file subtractable.sakura
#! @author John Christman (sorakatadzuma@gmail.com)
#! @copyright Malunal Studios, LLC.
#! @license MIT
#!
#! Contains the subtractable trait, which asks for the method `-` calls between
#! two values of one type.
module core;
#! A type whose values subtract from another of the type, giving one more.
#!
#! `a - b` calls `sub`, and `a -= b` writes what it gives over `a`. A type has
#! `-` by declaring the method, and may declare others taking or giving other
#! types, as `instant::sub(&this, since: &instant): duration`. The trait is
#! what generic code asks for to subtract two values of a type. Numbers are
#! subtractable without declaring anything.
pub trait subtractable {
#! Subtracts another value from this one, as `-` does.
#! @param this The value to subtract from.
#! @param other The value to subtract.
#! @returns The difference.
def sub(&this, other: &self): self;
}