10 lines
559 B
Rust
10 lines
559 B
Rust
// expect: run
|
|
// result: 42
|
|
// grant: heap=mem.alloc:4096
|
|
// phase: 6
|
|
// spec: docs/spec/15-source-language.md §10; docs/spec/03-memory-model.md §25
|
|
module test.own_array_content
|
|
struct Plain { item: u64 }
|
|
fn make<T: Copy>(value: T, heap: cap<mem.alloc>) -> own_array<T> effects [mem.alloc] { return own.array(2, move value, heap) or trap; }
|
|
fn main(heap: cap<mem.alloc>) -> u64 effects [mem.alloc] { let values = make::<Plain>(Plain { item: 21u64 }, heap); let n = { ref items = values; items[0].item + items[1].item }; own.free(move values); return n; }
|