Mojo实现unsafe pointer详解及接口说明

anypointer

Implement a generic unsafe pointer type.

You can import these APIs from the memory package. For example:

from memory.anypointer import AnyPointer

AnyPointer

This is a pointer type that can point to any generic value that is movable.

Parameters:

  • T (Movable): The pointer element type, which must be movable.

Aliases:

  • pointer_type = pointer<:trait<@stdlib::@builtin::@value::@Movable> T>: The underlying pointer type.

  • mlir_ref_type = !lit.ref<:trait<@stdlib::@builtin::@value::@Movable> T, mut #lit.lifetime>

Fields:

  • value (pointer<:trait<@stdlib::@builtin::@value::@Movable> T>): The underlying pointer.

Implemented traits:

AnyType, Boolable, CollectionElement, Copyable, EqualityComparable, Intable, Movable, Stringable

Methods:

__init__

__init__() -> Self

Create a null pointer.

Returns:

A null pointer.

__init__(value: pointer<:trait<_stdlib::_builtin::_value::_Movable> T>) -> Self

Create a pointer with the input value.

Args:

  • value (pointer<:trait<_stdlib::_builtin::_value::_Movable> T>): The input pointer to construct with.

Returns:

A null pointer.

__bool__

__bool__(self: Self

你可能感兴趣的:(Mojo,mojo,Mojo,pointer,Mojo,anypointer,mojo,pointer详解,mojo,pointer接口,mojo入门,mojo,基础教程)