Files
sakurac/tests/programs/traits_see_through_aliases_1.sakura
T
2026-11-19 04:54:17 -06:00

12 lines
365 B
Plaintext

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)}");
}