Initial Commit
This commit is contained in:
782 files changed
+145156
No files matched your search
@@ -0,0 +1,11 @@
|
||||
import std::io;
|
||||
type bytes = span<u8>;
|
||||
type count = u64;
|
||||
trait viewer<T> { def see(&this, from: u64): span<T>; }
|
||||
struct box : viewer<u8> { var n: u8[3]; }
|
||||
def box::see(&this, from: count): bytes { return this.n[from:3 - from]; }
|
||||
def use(v: &viewer<u8>): u64 { return v.see(1).length; }
|
||||
def main(): void {
|
||||
val b := box{ n = [1, 2, 3] };
|
||||
println($"{use(&b)}");
|
||||
}
|
||||
Reference in new issue
Block a user