IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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:

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.

Was this page helpful?