Owners free what they hold

Buffer, Array<T>, and Box<T> are owner types: each one holds memory that is freed exactly once, by deinit(). Ownership is part of the type, so there is nothing to annotate.

Pair the construction with a defer and the release happens on every exit from the block, including return, ?, break, and continue. view() hands out a read-only look at the bytes; it borrows, so it stays valid only while the owner does.

fn main() {
  let mut text = Buffer.new()
  defer text.deinit()
  text.append("Hello ").unwrap()
  text.append("moon").unwrap()
  println(text.view())
}
Output & diagnostics
Expected:
Hello moon
Ctrl/⌘+Enter runs the current lesson.