Pointer and Reference Types
Jiang separates ownership, borrow capability, raw-pointer capability, and binding mutability. Resource movement and lifetime rules are covered in Ownership, Borrowing & Lifetimes.
Pointer and Reference Forms
Section titled “Pointer and Reference Forms”T^: an owning pointer.T&: a shared readonly non-owning borrow.T&!: a unique mutable non-owning borrow. It cannot be implicitly copied.T*: a readonly raw pointer for FFI, ABI, and low-level code.T*!: a writable raw pointer.T[]&: a borrowed slice.T[]^: an owning slice.T[:S]&: a borrowed sentinel slice whose sentinel value isS.
Only T^ and T[]^ express language-level ownership. Use these surface forms directly in source.
Type-level ! is supported only after & or *: T&! and T*!. A ! after a binding name has a
different purpose—it lets that variable, parameter, global, or field be reassigned and does not
change its type.
Creating Borrows and Raw Pointers
Section titled “Creating Borrows and Raw Pointers”ref() and ptr() never manufacture write capability. The mutable forms are mut_ref() and
mut_ptr(), and they require a writable source place. Raw-pointer creation, casts, and indexing
remain inside unsafe.
Dereference and Member Access
Section titled “Dereference and Member Access”T^ can auto-dereference when the expected type is T; $.get() requests an explicit pointee read:
Member access can pass through an owning pointer:
References and raw pointers use $.get() for explicit reads. Writing requires a unique mutable
borrow or mutable-pointee raw pointer:
Raw Pointer Indexing
Section titled “Raw Pointer Indexing”T* and T*! can point into contiguous memory, but carry neither a length nor a sentinel guarantee.
The old T[*] and T[*:S] types have been removed. Indexing is always unsafe:
Use T[]& when the API should carry a runtime length, and T[:S]& when it should carry a sentinel
guarantee.
Void* and Void*! cannot be dereferenced or indexed because they have no element type. Cast to a
concrete raw-pointer type before accessing memory.
Implicit Operation Layer
Section titled “Implicit Operation Layer”$ prevents receiver auto-dereference and enters the implicit operation layer. Operations such as
$.get(), $.set(), $.ref(), $.mut_ref(), $.ptr(), $.mut_ptr(), and $.move() are covered in
Implicit Operation Layer.