summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-27 01:22:42 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-27 01:22:42 +0000
commit938773d9cc062fd028f6560b1127a2ecd23f61c3 (patch)
tree403aacd629975440ba23a645975c34a141d634ee /std
parent2f47bdf7f49f05bd421e4182635f489c8cae01b3 (diff)
Fixed constant hex/oct bug + Fixed some of the examples (work in progress) + added bootloader example (I will add some docs)
Diffstat (limited to 'std')
-rw-r--r--std/slice.zc27
1 files changed, 27 insertions, 0 deletions
diff --git a/std/slice.zc b/std/slice.zc
new file mode 100644
index 0000000..778c6ed
--- /dev/null
+++ b/std/slice.zc
@@ -0,0 +1,27 @@
+
+struct Slice<T> {
+ data: T*;
+ len: usize;
+}
+
+impl Slice<T> {
+ fn length(self) -> usize {
+ return self.len;
+ }
+
+ fn is_empty(self) -> bool {
+ return self.len == 0;
+ }
+
+ fn get(self, idx: usize) -> Option<T> {
+ if (idx >= self.len) {
+ return Option<T>::None();
+ }
+ return Option<T>::Some(self.data[idx]);
+ }
+
+ fn at(self, idx: usize) -> Option<T> {
+ if idx >= self.len { return Option<T>::None(); }
+ return Option<T>::Some(self.data[idx]);
+ }
+}