Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-11-19 04:54:17 -06:00
commit f086abcea6
789 files changed
+149185

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
#! @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<Ts...> {
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<Ts...>::of(items: Ts...): tuple<Ts...> {
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<Ts...>::at<const index: u64>(&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<Ts...>::at<const index: u64>(&mut this): &mut Ts...[index] {
return &mut this.items[index];
}