ref.borrow
← ref dialect
Create a pointer to an owner's exact managed payload without consuming the owner. Null produces null. The pointer remains live through its final reachable use, even when the original owner is released first. The compiler acquires protection when it cannot prove a covering owner and retires that protection after the final use. The source owner's explicit lifetime is unchanged.
Operation contract
| Property |
Value |
| Semantic phase |
executable |
| Traits |
UniqueIdentity, ObservableEffect |
| Ownership effects |
borrow owner (by_value), alias pointer from owner |
Signature
| Kind |
Name |
Type |
Cardinality |
Description |
| Operand |
owner |
managed_reference |
required |
— |
| Result |
pointer |
managed_reference |
required |
— |
Examples
%pointer = ref.borrow %owner : ref<@Frame> -> ptr<@Frame>