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
maybe_null_pointer
def maybe_null_pointer[dtype: DType, //, present: Bool](ptr: Pointer[Scalar[dtype]]) -> NonNullPointer[dtype] if present else NullPointer[dtype]
Wraps ptr as a NonNullPointer when present, else drops it.
Lets a caller that knows at compile time whether an optional operand is
supplied turn it into an OptionalPointer, so the kernels it reaches are
specialized on the operand's presence rather than branching on null.
Parameters:
- โdtype (
DType): Element type of the pointed-to values (inferred). - โpresent (
Bool): Whetherptris a live operand.
Args:
- โptr (
Pointer[Scalar[dtype]]): The operand's pointer; ignored whenpresentis False.
Returns:
NonNullPointer[dtype] if present else NullPointer[dtype]: The OptionalPointer for ptr.