For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
as_optional_reg
def as_optional_reg[T: OptionalPointer](ptr: T) -> OptionalReg[Pointer[Scalar[T.dtype], MutAnyOrigin, address_space=T.address_space]]
Converts an OptionalPointer to the runtime-nullable OptionalReg form.
For handing a typed optional operand to code that still branches on null at runtime.
Parameters:
- T (
OptionalPointer): TheOptionalPointertype (inferred).
Args:
- ptr (
T): The pointer to convert.
Returns:
OptionalReg[Pointer[Scalar[T.dtype], MutAnyOrigin, address_space=T.address_space]]: None when T is null, else the wrapped pointer.