Fix sample.

This commit is contained in:
Christoffer Lerno
2025-01-09 01:33:58 +01:00
parent 11f9365eb0
commit c78bb45f2f

View File

@@ -22,7 +22,8 @@ fn void Resource.deinit(Resource this) => io::printfn("close %s", this.name);
macro void! @open_with(String name; @body(Resource resource))
{
Resource resource = resource_init(name)!;
defer {
defer
{
io::printn("Using open_with to close");
resource.deinit();
}
@@ -46,7 +47,7 @@ fn Resource! prep_out(String out_name, String[] prep_names)
fn void main()
{
Resource writer = prep_out("out", String[] { "a", "b"});
Resource writer = prep_out("out", String[] { "a", "b"})!!;
defer writer.deinit();
io::printn("use out");
}