Mojo stringref详解及相关说明

stringref

Implements the StringRef class.

StringRef

Represent a constant reference to a string, i.e. a sequence of characters and a length, which need not be null terminated.

Fields:

  • data (DTypePointer[si8, 0]): A pointer to the beginning of the string data being referenced.

  • length (Int): The length of the string being referenced.

Implemented traits:

AnyType, Boolable, CollectionElement, Copyable, EqualityComparable, Hashable, IntableRaising, Movable, Sized, Stringable

Methods:

__init__

__init__(str: StringLiteral) -> Self

Construct a StringRef value given a constant string.

Args:

  • str (StringLiteral): The input constant string.

Returns:

Constructed StringRef object.

__init__(ptr: Pointer[SIMD[si8, 1], 0], len: Int) -> Self

Construct a StringRef value given a (potentially non-0 terminated string).

The constructor takes a raw pointer and a length.

Args:

  • ptr

你可能感兴趣的:(Mojo,mojo,Mojo,stringref,Mojostringref详解,mojo入门教程,mojo基础教程,mojo学习,mojo入门基础)