Initial Commit
This commit is contained in:
706 files changed
+135430
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import std::io;
|
||||
struct noisy : owning { var name: span<u8>; }
|
||||
def noisy::new(name: span<u8>): noisy { return noisy { name = name }; }
|
||||
def noisy::close(&mut this): void { println($"close {this.name}"); }
|
||||
def noisy::rename(&mut this, name: span<u8>): void { this.name = name; }
|
||||
union held { var code: i64; var one: noisy; }
|
||||
def main(): void {
|
||||
var h: held = noisy::new("a");
|
||||
match h {
|
||||
one(&mut got) => { println($"holds {got.name}"); got.rename("renamed"); }
|
||||
code(n) => { println($"code {n}"); }
|
||||
}
|
||||
if h is one(&got) { println($"still {got.name}"); }
|
||||
var c: held = 7;
|
||||
if c is one(&got) { println("wrong"); }
|
||||
if c is code(n) { println($"code {n}"); }
|
||||
println("end");
|
||||
}
|
||||
Reference in new issue
Block a user