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