Skip to main content
Log in

Mojo trait

WritableCollectionElement

The WritableCollectionElement trait denotes a trait composition of the CollectionElement and Writable traits.

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

Implemented traits

AnyType, CollectionElement, Copyable, Movable, UnknownDestructibility, Writable

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.

write_to

write_to[W: Writer](self: _Self, mut writer: W)

Formats the string representation of this type to the provided Writer.

Parameters:

  • W (Writer): A type conforming to the Writable trait.

Args:

  • writer (W): The type conforming to Writable.