Skip to main content
Log in

Mojo trait

BytesCollectionElement

The BytesCollectionElement trait denotes a trait composition of the CollectionElement and AsBytes.

This is useful to have as a named entity since Mojo does not currently support anonymous trait compositions to constrain on CollectionElement & AsBytes in the parameter.

Implemented traits

AnyType, AsBytes, CollectionElement, Copyable, Movable, UnknownDestructibility

Methods

__copyinit__

__copyinit__(out self: _Self, existing: _Self, /)

Create a new instance of the value by copying an existing one.

Args:

  • existing (_Self): The value to copy.

__moveinit__

__moveinit__(out self: _Self, owned existing: _Self, /)

Create a new instance of the value by moving the value of another.

Args:

  • existing (_Self): The value to move.

as_bytes

as_bytes(ref self: _Self) -> Span[SIMD[uint8, 1], self_is_origin]

Returns a contiguous slice of the bytes owned by this string.

Notes: This does not include the trailing null terminator.

Returns:

A contiguous slice pointing to the bytes owned by this string.