#! @file tuple.sakura #! @author John Christman (sorakatadzuma@gmail.com) #! @copyright Malunal Studios, LLC. #! @license MIT #! #! Contains `tuple`, values of any number of types kept together, each reached #! by its index, as `pair` keeps two, each reached by its name. module core; #! Values of any number of types kept together in order, each reached by its #! index, known while compiling, as `t.items[0]` or `t.at::<0>()`. What closes #! among them is closed where the tuple is, the last first, as fields are. #! @tparam Ts The types of the values. pub struct tuple { pub var items: Ts...; #! The values, one of each type, as a pack is used. } #! Makes a tuple of the values given, moving those that close into it. #! @param items The values. #! @returns The tuple. pub def tuple::of(items: Ts...): tuple { return tuple { items = items }; } #! Reads the value at an index. #! @tparam index The index, known while compiling. #! @param this The tuple to read. #! @returns The value. pub def tuple::at(&this): &Ts...[index] { return &this.items[index]; } #! Reaches the value at an index to write it. #! @tparam index The index, known while compiling. #! @param this The tuple to write. #! @returns The value. pub def tuple::at(&mut this): &mut Ts...[index] { return &mut this.items[index]; }